我在我的rails應用程序中使用devise進行身份驗證。我可以登錄和註銷,也可以註冊。但是,一旦用戶登錄,我想提供一種方法讓用戶修改他的登錄密碼。爲此,該應用程序提供了一個指向'edit_user_registration_path'的鏈接,該鏈接顯示在下面的rake路由輸出中。rails設計edit_user_registration
當用戶點擊下面的修改密碼的鏈接,
<li><%= link_to "Change Password", edit_user_registration_path %></li>
我收到以下錯誤
ActionController::RoutingError (No route matches {:action=>"edit", :controller=>"users"}):
我有演出,編輯一個UsersController和更新操作。編輯操作是更新用戶模型的其他列。
的路由進行設置如下
devise_for :users
resources :users, only: [:show, :edit, :update]
耙路線輸出 -
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
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
root / home#index
控制檯日誌低於
Started GET "https://stackoverflow.com/users/edit" for 127.0.0.1 at 2013-02-21 15:21:38 +0530
Processing by Devise::RegistrationsController#edit as HTML
User Load (0.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Rendered devise/registrations/edit.html.erb within layouts/application (15.9ms)
Rendered layouts/_shim.html.erb (0.0ms)
Rendered layouts/_messages.html.erb (0.1ms)
Rendered layouts/_header.html.erb (42.5ms)
Completed 500 Internal Server Error in 99ms
ActionController::RoutingError (No route matches {:action=>"edit", :controller=>"users"}):
app/views/layouts/_header.html.erb:22:in `_app_views_layouts__header_html_erb__267315279__621159918'
app/views/layouts/application.html.erb:20:in `_app_views_layouts_application_html_erb__982964301_89714280'
你能不能告訴我們: 應用程序/視圖/佈局/ _header.html.erb:22 – Leito 2013-02-21 19:24:44
我相信你自己調用edit_user_path,而不是告訴它要編輯哪個用戶。 – Leito 2013-02-21 19:25:57
正如你所猜測的,我正在使用edit_user_path。這有什麼問題嗎?如何在這裏指出用戶?