I am new to rails and this is my first app. Currently using rails 3.2.11 and devise 2.2.3 for authentication.
The problem is after signing in, the application returns 404 and says that it was not able to find a route for 'users' controller and 'show' action.
I have a home controller for static pages and a user controller for the user. I have generated the User model using the rails generate command. My config/routes.rb is as below.
devise_for :users
resources :users
root :to => 'home#index'
Started POST "/users/sign_in" for 127.0.0.1 at 2013-01-29 15:44:25 +0530 Processing by Devise::SessionsController#create as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"cHXjNbgzEx2YsHX/AMb1oxjStY75IVHc9wT40NUOdJM=", "user"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"} User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."email" = '[email protected]' LIMIT 1 (0.1ms) begin transaction (0.5ms) UPDATE "users" SET "last_sign_in_at" = '2013-01-29 10:06:46.145781', "current_sign_in_at" = '2013-01-29 10:14:26.063767', "sign_in_count" = 66, "updated_at" = '2013-01-29 10:14:26.067024' WHERE "users"."id" = 1 (188.0ms) commit transaction Completed 404 Not Found in 365ms
ActionController::RoutingError (No route matches {:action=>"show", :controller=>"users"}): app/controllers/application_controller.rb:5:in `after_sign_in_path_for'
And I have modified the applications controller as below
def after_sign_in_path_for(resource)
user_url(resource)
end
What I am trying to do is that once the user logs in, I want to show the user specific information. For that I modified the after_sign_in_path_for(). Any hints on how I can get the desired results?
My rake routes output is below
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
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
root / home#index