I am getting this error whenever I go to /users/edit when signed in:
No route matches {:action=>"show", :controller=>"users"}
Why is the users/edit trying to look for the show action in the users controller?
routes.rb
devise_for :users do
get 'users', :to => 'users#show', :as => :user_root # Rails 3
end
resources :users, :only => [:index, :show]
authenticated :user do
root :to => 'home#index'
end
root :to => 'home#index'
rake routes:
user_root GET /users(.:format) users#show
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(.:forma 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
users GET /users(.:format) users#index
user GET /users/:id(.:format) users#show
root / home#index
root / home#index
Weird!
So I stepped through all my last changes and found out the issue was with this line of code located in views/layouts/application.html.erb:
For some reason when their is a link to user_path in the layout file, the routing in the site gets all messed up.
To fix it I just changed
user_pathtocurrent_userso my new link looks like this:What is really weird is that when you use a link to
user_pathanywhere but the layout/application.html.erb file the routing works fine.