Rails 3 Root Route问题?

时间:2010-12-11 20:32:13

标签: ruby-on-rails ruby-on-rails-3

嘿伙计们我在使用rails root rout时遇到了一些问题。出于某种原因,我无法获得根URL(localhost:3000 /)来路由到适当的地方。

我已经构建了一个全新的app并使用scaffold来生成“问题”模型。我可以确认存在“索引”操作(默认情况下来自scaffold)

这是我的代码:

Fbauth::Application.routes.draw do
  resources :questions
  root :to => 'questions#index'
end

Rake Routes输出:

 (in /home/jsfour/rails3_apps/fbauth)
    questions GET    /questions(.:format)          {:action=>"index", :controller=>"questions"}
              POST   /questions(.:format)          {:action=>"create", :controller=>"questions"}
 new_question GET    /questions/new(.:format)      {:action=>"new", :controller=>"questions"}
edit_question GET    /questions/:id/edit(.:format) {:action=>"edit", :controller=>"questions"}
     question GET    /questions/:id(.:format)      {:action=>"show", :controller=>"questions"}
              PUT    /questions/:id(.:format)      {:action=>"update", :controller=>"questions"}
              DELETE /questions/:id(.:format)      {:action=>"destroy", :controller=>"questions"}
         root        /(.:format)                   {:controller=>"questions", :action=>"index"}

这是什么问题?为什么localhost:3000 /给我“欢迎使用rails”消息?

1 个答案:

答案 0 :(得分:30)

您需要删除public / index.html - 它将优先于您的root操作。