I have this application where I use Devise and, after login the user is redirected to a blank page with the path /users/sign_in.user.
Why is Devise redirecting to this path? Here’s the log entry I get:
Started POST "/users/sign_in.user" for 127.0.0.1 at 2011-11-10 15:56:03 -0200
Processing by Users::SessionsController#create as
Parameters: {"utf8"=>"✓", "authenticity_token"=>"ukqyLFgApCSybuIlVynPwj/xgdI/WuHLxoFxOsY4wgQ=", "user"=>{"email"=>"felipe.coury@gmail.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Entrar"}
User Load (1.8ms) SELECT `users`.* FROM `users` WHERE `users`.`email` = 'felipe.coury@gmail.com' LIMIT 1
(0.2ms) BEGIN
(1.0ms) UPDATE `users` SET `last_sign_in_at` = '2011-11-09 18:47:04', `current_sign_in_at` = '2011-11-10 17:56:04', `sign_in_count` = 14, `updated_at` = '2011-11-10 17:56:04' WHERE `users`.`id` = 1
(0.3ms) COMMIT
Completed 406 Not Acceptable in 112ms
Here’s my complete routes.rb file:
MyApp::Application.routes.draw do
root :to => "site#home"
match 'biblioteca' => 'site#library', :as => :library
devise_for :users, :controllers => { :sessions => "users/sessions" }
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
resources :cursos
resources :matriculas
resources :modulo_statuses
end
I tried using after_sign_in_path_for in ApplicationController:
def after_sign_in_path_for(resource_or_scope)
Rails.logger.info "***** LOGGED IN, GOING TO #{root_path}"
root_path
end
But the log entry doesn’t even appear.
Does anyone have any idea why this happens?
This is probably happening because something like this is being called:
user_session_path(user)and you actually don’t need the user as argument, so Rails treats it as the format. This is likely wrong in theform_forcall in your sign in view.after_sign_in_path_foris not being called because Rails is not considering the given URL a valid request (that’s why the response is 406 acceptable).