1

我试图让我所有的设计路线都成为我想要的方式:

devise_for :users, :controllers => { :registrations => 'registrations' }
  devise_scope :user do
    get 'join' => 'devise/registrations#new', :as => :new_user_registration
    post 'join' => 'devise/registrations#create', :as => :user_registration
    get 'login' => 'devise/sessions#new', :as => :new_user_session
    post 'login' => 'devise/sessions#create', :as => :user_session
    delete 'logout' => 'devise/sessions#destroy', :as => :destroy_user_session
    get 'account_settings' => 'devise/registrations#edit', :as => :edit_user_registration
    put 'account_settings' => 'devise/registrations#update', :as => :update_user_registration
    get 'forgot_password' => 'devise/passwords#new', :as => :new_user_password
    get 'user', :to => 'user_pages#home', :as => :user_root
  end

  match '/user' => 'user_pages#home', :as => :user_root

当我转到帐户设置(或设计编辑注册)并尝试更新它时。我得到错误:

Routing Error

No route matches [PUT] "/join"

它应该回到主页。为什么我会收到此错误?我如何解决它?

编辑

这是所有设计路线和我制作的路线:

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)        registrations#cancel
       user_registration POST   /users(.:format)               registrations#create
   new_user_registration GET    /users/sign_up(.:format)       registrations#new
  edit_user_registration GET    /users/edit(.:format)          registrations#edit
                         PUT    /users(.:format)               registrations#update
                         DELETE /users(.:format)               registrations#destroy
   new_user_registration GET    /join(.:format)                devise/registrations#new
       user_registration POST   /join(.:format)                devise/registrations#create
        new_user_session GET    /login(.:format)               devise/sessions#new
            user_session POST   /login(.:format)               devise/sessions#create
    destroy_user_session DELETE /logout(.:format)              devise/sessions#destroy
  edit_user_registration GET    /account_settings(.:format)    devise/registrations#edit
       new_user_password GET    /forgot_password(.:format)     devise/passwords#new

我很难看到这个,看看我需要改变什么。因此,如果有人知道这将有很大帮助。谢谢。

4

1 回答 1

1

做一行更改,我在这里写完整的代码:

devise_for :users, :controllers => { :registrations => 'registrations' }
  devise_scope :user do
    get 'join' => 'devise/registrations#new', :as => :new_user_registration
    put 'join' => 'devise/registrations#create', :as => :user_registration
    get 'login' => 'devise/sessions#new', :as => :new_user_session
    post 'login' => 'devise/sessions#create', :as => :user_session
    delete 'logout' => 'devise/sessions#destroy', :as => :destroy_user_session
    get 'account_settings' => 'devise/registrations#edit', :as => :edit_user_registration
    put 'account_settings' => 'devise/registrations#update', :as => :update_user_registration
    get 'forgot_password' => 'devise/passwords#new', :as => :new_user_password
    get 'user', :to => 'user_pages#home', :as => :user_root
  end

  match '/user' => 'user_pages#home', :as => :user_root

在上面我改变了行

post 'join' => 'devise/registrations#create', :as => :user_registration

put 'join' => 'devise/registrations#create', :as => :user_registration

或提出您的请求发布请求。

于 2012-09-18T18:48:45.253 回答