0

我是 Rails 新手,我无法通过设计来确定 Rails 3 中的路由

当我路由到用户页面时,我得到了这个丑陋的错误: http ://s9.postimage.org/nlyxhlk5b/Devise_routing.png

在我的路线中

#Resources for users

devise_for :users, :controllers => { :registrations => "registrations" }

resource :users do
  get 'welcome'
end

这些是我的用户路线

更新

                       root        /                                               members#welcome
           new_user_session GET    /users/sign_in(.:format)                        devise/sessions#new
               user_session POST   /users/sign_in(.:format)                        devise/sessions#create
       destroy_user_session DELETE /users/sign_out(.:format)                       devise/sessions#destroy
              user_password POST   /users/password(.:format)                       devise/passwords#create
          new_user_password GET    /users/password/new(.:format)                   devise/passwords#new
         edit_user_password GET    /users/password/edit(.:format)                  devise/passwords#edit
                            PUT    /users/password(.:format)                       devise/passwords#update
   cancel_user_registration GET    /users/cancel(.:format)                         devise/registrations#cancel
          user_registration POST   /users(.:format)                                devise/registrations#create
      new_user_registration GET    /users/sign_up(.:format)                        devise/registrations#new
     edit_user_registration GET    /users/edit(.:format)                           devise/registrations#edit
                            PUT    /users(.:format)                                devise/registrations#update
                            DELETE /users(.:format)                                devise/registrations#destroy

我应该没有 2 个用户资源吗?我相信他们可能会以某种方式发生冲突,或者我只是错过了什么?

更新

我忘了提到我正在覆盖默认的设计注册控制器

 class RegistrationsController < Devise::RegistrationsController
  protected

  # Redirect to welcome page after a successful registration
  def after_sign_up_path_for(resource)
    '/users/welcome'
  end
 end
4

1 回答 1

1

删除用户控制器 删除注册控制器

消除

resource :users do
get 'welcome'
end

将此添加到您的路线

# Directing the user after login
 authenticated :user do
root :to => 'recipes#index'

结尾

改变

devise_for :users, :controllers => { :registrations => "registrations" }

devise_for :users

让我知道情况如何

于 2012-11-23T20:04:49.747 回答