diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a29a2360..f9cef729 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,12 +8,12 @@ class ApplicationController < ActionController::Base helper_method :authenticated? helper_method :admin? - after_filter :store_location - - def store_location - # store last url - this is needed for post-login redirect to whatever the user last visited. - if (!request.fullpath.match("/users/") && !request.xhr?) # don't store ajax calls - session[:previous_url] = request.fullpath + def after_sign_in_path_for(resource) + sign_in_url = url_for(:action => 'new', :controller => 'sessions', :only_path => false, :protocol => 'http') + if request.referer == sign_in_url + super + else + stored_location_for(resource) || request.referer || root_path end end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 7062ead0..0f0be9ba 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -1,12 +1,10 @@ -class RegistrationsController < Devise::RegistrationsController +class Users::RegistrationsController < Devise::RegistrationsController protected - - def after_sign_in_path_for(resource) - session[:previous_url] || root_path - end - - def after_sign_up_path_for(resource) - root_path - end - -end + def after_sign_up_path_for(resource) + signed_in_root_path(resource) + end + + def after_update_path_for(resource) + signed_in_root_path(resource) + end +end \ No newline at end of file diff --git a/app/controllers/users/passwords_controller.rb b/app/controllers/users/passwords_controller.rb new file mode 100644 index 00000000..d1405f6a --- /dev/null +++ b/app/controllers/users/passwords_controller.rb @@ -0,0 +1,6 @@ +class Users::PasswordsController < Devise::PasswordsController + protected + def after_resetting_password_path_for(resource) + signed_in_root_path(resource) + end +end \ No newline at end of file diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb new file mode 100644 index 00000000..5fff2f1c --- /dev/null +++ b/app/controllers/users/registrations_controller.rb @@ -0,0 +1,10 @@ +class Users::RegistrationsController < Devise::RegistrationsController + protected + def after_sign_up_path_for(resource) + signed_in_root_path(resource) + end + + def after_update_path_for(resource) + signed_in_root_path(resource) + end +end diff --git a/app/views/layouts/_account.html.erb b/app/views/layouts/_account.html.erb index 0cee5c7f..ffe69b7e 100644 --- a/app/views/layouts/_account.html.erb +++ b/app/views/layouts/_account.html.erb @@ -24,7 +24,7 @@