I get the following error trying to access <%= link_to('Edit registration', 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
My routes are as follows:
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
Thank your very much for your help!
<%= link_to('Edit registration', edit_user_registration_path) %>.
是不是通过了我
<%= link_to('Edit registration', edit_user_registration_path(@user)) %>.
The problem isn't the edit registration link, the reason is this in your routes:
edit_profile GET /profiles/:id/edit(.:format) profiles#edit
And the link to the profiles page:
<%= link_to 'Edit Profile', edit_profile_path %>
edit_profile_path expects an id
You need to pass in the object on which you want to edit a profile:
<%= link_to 'Edit Profile', edit_profile_path(@user) %>
Or, if you want profiles to only act on the current user, set it up in routes.rb as a singular resource:
resource :profile
I had the same issue. Solved it by editing routes.rb:
Rails.application.routes.draw do
if Rails.env == 'production'
default_url_options :host => "myserver.com"
else
default_url_options :host => "localhost:3000"
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.