Ruby on rails Rails 3-更改索引

Ruby on rails Rails 3-更改索引,ruby-on-rails,ruby-on-rails-3,routes,Ruby On Rails,Ruby On Rails 3,Routes,我使用的是Rails 3,我觉得更改索引路由的语法(http://localhost:3000)与以前的版本不同 我想打开employees控制器的动态索引页面(index.html.erb)(现在可以使用localhost:3000/employees打开)作为默认页面(localhost:3000)。我认为这很容易,因为在路线上写着: # You can have the root of your site routed with "root" # just remember to

我使用的是Rails 3,我觉得更改索引路由的语法(http://localhost:3000)与以前的版本不同

我想打开employees控制器的动态索引页面(index.html.erb)(现在可以使用localhost:3000/employees打开)作为默认页面(localhost:3000)。我认为这很容易,因为在路线上写着:

  # You can have the root of your site routed with "root"
  # just remember to delete public/index.html.
  # root :to => "welcome#index"
这就是我实际做的:我删除了
public/index.html
,并将
root:to=>“employees#index”
。 但当我打开服务器并打开localhost:3000时,它仍然会打开“欢迎来到国外!”-页面。真奇怪

所以我用谷歌搜索了这个问题,找到了答案,上面写着,我应该把这个写进我的路由文件:

map.root:controller=>employees',:action=>index'

这里也是一样-我仍然得到“欢迎来到国外!”-页面,rails外壳显示“未定义的局部变量或方法‘map’”。(我认为这是Rails 2的旧语法…?)

匹配”/“=>”员工#索引“
表示路由错误:没有路由匹配“

那么我做错了什么?我怎样才能解决这个问题

为什么在Rails 3中使用“map”?应该是:

   root :to => "employees#index"

我认为问题在于饼干。请清除Cookie并刷新页面。

看起来您没有删除
public/index.html
:)是否确实在删除public/index.html后重新启动了服务器?嘿???我不明白,但现在它起作用了。我肯定(100%)删除了public/index.html。我还重新启动了服务器。我甚至清理了我的回收站。。。那毕竟没用。唯一有用的是从文件夹中删除图像(public/images/rails.png)。在那之后,我得到了我的索引页。真奇怪。。。无论如何谢谢你!是的,我意识到这不是Rails 3的正确方法。我对Rails非常陌生,因此我不习惯这些惯例,在谷歌上搜索答案让我感到困惑:)