这几天看书自己写东西,有些东西很简单但花了不少时间
app/view/layouts 用来放layout文件 在controller里写 layout :"layout文件名" 就可以把对应的文件放入作好的layout模版中减少代码 render(:layout => flase) 禁用已有的layout render(:layout => "layout/sameotherlayout" 改变layout
class DbaController < ApplicationController
def abc
redirect_to :controller=>:home, :action=>:index
end
end
class HomeController < ApplicationController
def index
end
end
不同controll之间的action调用。
config/routes.rb map.home '', :controller => 'index' , :action => 'index' 设定index跳转的地方。。。当然如果你不把public下的index.html文件删了估计也不会有用。
你在北京哪里上班呀,我在中关村这边上班,以后要多多向你请教,嘿嘿~!!!! :)
rake db:migrate 作用就是把db/migrate/目录下的所有数据文件加到数据库中去 但这个东西真的很麻烦 1:以后尽量一个改,否则死人死人。。 2:尽量不要用force,想要加字段减字段用 add_column :users, :activated, :boolean 如果用了force想要后退版本时会很麻烦 (第一次与第二次同时drop了一个同名的table) 3:index不用删,为了删index我又查了一下午,发现不是这回事。 4:text类型是没有初值的。当时大脑在想什么。。。迷糊。