尝试访问<%= link_to('Edit registration',edit_user_registration_path)%>时出现以下错误。设计路由错误edit_user_registration_path
Routing Error
No route matches {:action=>"edit", :controller=>"profiles"}
Try running rake routes for more information on available routes.
的routes.rb
xyz::Application.routes.draw do
root :to => "home#index"
resources :profiles
devise_for :users
authenticated :user do
root :to => "home#index"
end
end
我的路线如下:
root / home#index
profiles GET /profiles(.:format) profiles#index
POST /profiles(.:format) profiles#create
new_profile GET /profiles/new(.:format) profiles#new
edit_profile GET /profiles/:id/edit(.:format) profiles#edit
profile GET /profiles/:id(.:format) profiles#show
PUT /profiles/:id(.:format) profiles#update
DELETE /profiles/:id(.:format) profiles#destroy
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
root / home#index
感谢您的非常对你有所帮助!
错误看起来像它来自edit_profile路线,而不是edit_user_registration路线。这应该是在编辑个人资料页面,如果是的话,你可以告诉我们你如何链接到那里? – 2012-07-26 09:29:11
我从配置文件视图中添加了一个链接,如下所示:<%= link_to'编辑注册',edit_user_registration_path(current_user)%>' - 呈现的链接看起来像http:// localhost:3000/users/edit.10(with current_user )和http:// localhost:3000/users/edit(不含current_user)。我认为设计是把配置文件控制器作为资源......但如何解决这个问题?我用于编辑配置文件页面的路径是<%= link_to'编辑配置文件',edit_profile_path%> – 2012-07-26 11:03:30