⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 work_controller.rb

📁 RubyonRailsC.zip ruby on rails的源码
💻 RB
字号:
class WorkController < ApplicationController
	scaffold :work
	
	def index
		render_text "<a href=\"/work/list\">back</a>"
		#render(:text => "")
	end
	
	def list
		@countOfPage = 2  #每一页显示的留言条数
		@maxNumOfPage = 3    #显示当前页序号前后数字链接的最大数
		@works = Work.find_all  #所有留言的集合
		@unitCount = @works.length      #留言总条数
		@pageCount = (@unitCount+@countOfPage-1)/@countOfPage #总页数
		@thePage = @params["id"].to_i  #当前显示的页码
		if @thePage == nil 
			@thePage = 1
		elsif @pageCount == 0  #当数据库中没有任何数据时
			@thePage = 1
		elsif @thePage < 1 
			@thePage = 1
		elsif @thePage > @pageCount
			@thePage = @pageCount
		end
		@theUnit = (@thePage-1)*@countOfPage  #当前留言的序号
	end
	
	def new
		redirect_to :action => "list"
	end
	
	def create 
		work = Work.new(@params[:work])
		work["thedatetime"] = Time.now
		work["ip"] = request.remote_ip
		work.save
		redirect_to :action => "list"
		
	end
	
	def show
		redirect_to :action => "list"
		
	end
	
	def edit
		redirect_to :action => "list"
	endend

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -