Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect after signing out of ActiveAdmin

I'm trying to redirect users to my root_path which is / and allowed for unauthenticated users, but I can't seem to be able to change the default behavior of active admin.

I know active admin uses devise as the authentication mechanism, but I could not override the defaults for devise either.

I tried the following in my application_controller.rb (even though it's supposed to be the default):

# Overwriting the sign_out redirect path method
def after_sign_out_path_for(resource_or_scope)
  root_path
end

But I still see this in my logs:

Started GET "/admin/logout?locale=fr" for 127.0.0.1 at 2012-06-07 11:30:15 -0400
  Processing by ActiveAdmin::Devise::SessionsController#destroy as HTML
  Parameters: {"locale"=>"fr"}
  AdminUser Load (0.4ms)  SELECT `admin_users`.* FROM `admin_users` WHERE `admin_users`.`id` = 1 LIMIT 1
   (0.1ms)  BEGIN
   (0.3ms)  UPDATE `admin_users` SET `remember_created_at` = NULL, `updated_at` = '2012-06-07 15:30:15' WHERE `admin_users`.`id` = 1
   (0.5ms)  COMMIT
Redirected to http://localhost:3000/admin
Completed 302 Found in 47ms

So it sends me back to the login page.

like image 870
mbillard Avatar asked Jun 07 '12 15:06

mbillard


1 Answers

Fivell answer is slighty incorrect, because also login is redirected to root_path. Even better, you could override the specific Devise method:

ActiveAdmin::Devise::SessionsController.class_eval do
  def after_sign_out_path_for(resource_or_scope)
    "/wherever-you-want"
  end
end
like image 62
nebirhos Avatar answered Oct 28 '22 23:10

nebirhos