错误地设计路线控制器

时间:2011-02-02 20:06:03

标签: ruby-on-rails-3 devise

我在rails 3.0.3上遇到了设计1.1.5的问题。 我有一个控制器“站点”,动作“家”。当我执行“rake routes”时,一切都应该如此,但是当我在sign_up链接上单击我的站点时,它会返回错误:

No route matches {:action=>"home", :controller=>"devise/site"}

这是正确的控制器应该是“站点”,而不是“设计/站点”。 这是在我的routes.rb:

resources :articles

get "site/home"

get "site/about"

devise_for :users

但是当我看到“rake routes”时,一切看起来都很好。有任何想法吗?谢谢!

articles GET    /articles(.:format)            {:action=>"index", :controller=>"articles"}
         POST   /articles(.:format)            {:action=>"create", :controller=>"articles"}
new_article GET    /articles/new(.:format)        {:action=>"new", :controller=>"articles"}
edit_article GET    /articles/:id/edit(.:format)   {:action=>"edit", :controller=>"articles"}
article GET    /articles/:id(.:format)        {:action=>"show", :controller=>"articles"}
        PUT    /articles/:id(.:format)        {:action=>"update", :controller=>"articles"}
        DELETE /articles/:id(.:format)        {:action=>"destroy", :controller=>"articles"}
site_home GET    /site/home(.:format)           {:action=>"home", :controller=>"site"}
site_about GET    /site/about(.:format)          {:action=>"about", :controller=>"site"}
new_user_session GET    /users/sign_in(.:format)       {:action=>"new", :controller=>"devise/sessions"}
user_session POST   /users/sign_in(.:format)       {:action=>"create", :controller=>"devise/sessions"}
destroy_user_session GET    /users/sign_out(.:format)      {:action=>"destroy", :controller=>"devise/sessions"}
user_password POST   /users/password(.:format)      {:action=>"create", :controller=>"devise/passwords"}
new_user_password GET    /users/password/new(.:format)  {:action=>"new", :controller=>"devise/passwords"}
edit_user_password GET    /users/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
                   PUT    /users/password(.:format)      {:action=>"update", :controller=>"devise/passwords"}
user_registration POST   /users(.:format)               {:action=>"create", :controller=>"devise/registrations"}
new_user_registration GET    /users/sign_up(.:format)       {:action=>"new", :controller=>"devise/registrations"}
edit_user_registration GET    /users/edit(.:format)          {:action=>"edit", :controller=>"devise/registrations"}
                       PUT    /users(.:format)               {:action=>"update", :controller=>"devise/registrations"}
                       DELETE /users(.:format)               {:action=>"destroy", :controller=>"devise/registrations"}
root        /(.:format)                    {:action=>"home", :controller=>"site"}

1 个答案:

答案 0 :(得分:0)

注册链接的代码是什么?

尝试将您的routes.rb更改为(我认为当前描述的'home'和'about'的方式可能导致错误):

devise_for :users
resources :sites do
  get :home, :on => :member
  get :about, :on => :member
end

resources :articles

还要记住设置根路径,以便在用户登录时将其指向正确的视图。