问题描述
|
我试图让我的自定义主页显示出来,而不是“欢迎您乘坐Ruby on Rails”默认页面出现。在我的
config/routes.rb
文件中,行root :to => \'pages#home\'
允许它加载pages/home.html.erb
文件,并且按照route.rb文件的注释中的指示删除了public/index.html
。我使用语法“ 4”的所有其他网页都工作正常。我还需要做些什么来更新我的主页?
编辑:
有人要求我发布页面控制器。这里是:
class PagesController < ApplicationController
def home
@title = \"Home\"
end
def contact
@title = \"Contact\"
end
def about
@title = \"About\"
end
def help
@title = \"Help\"
end
end
我的.html.erb文件中引用了@title变量,但否则我的控制器几乎是空的。
解决方法
删除index.html后,您是否尝试过重新启动服务器?您是否清除了浏览器缓存?
, 你有一个PagesController吗?
rails generate controller pages home
, 我使用的语法(Rails 2.3)是:
map.root :controller => \"welcome\"
那去:index方法。如果您想转到:home,我想您应该添加:action。