我正试图让我所有的设计路线成为我希望它们的方式:
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"
它假设回到主页。为什么我会收到此错误?我该如何解决?
修改
以下是所有Devise路线和我制作的路线:
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
我很难看到这一点,看看我需要改变什么。所以如果有人知道它会有很大帮助。感谢。
答案 0 :(得分: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
或提出发布请求。