Rectangle 27 0

You don't have an admin variable to access, you need to check what the parameter is that you are being given.

def after_sign_in_path_for(resource)
  stored_location_for(resource) ||
    if resource.is_a?(Admin)
      admin_dashboard_path
    else
      user_path(resource)
    end
end

You should also not redirect inside this method, it should only return a path that devise can use.

rails g active_admin:install
if resource.is_a?(AdminUser)

Damn, this probably just saved me hours and hours of head-scratching. Thanks a lot!

ruby on rails - Devise + Active Admin Redirect - Stack Overflow

ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1 devise activeadmin
Rectangle 27 0

Solved the issue by changing my routes around. The ActiveAdmin routes need to come after the Devise routes, like so:

devise_for :users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)

Believe this occurred because I installed ActiveAdmin after I'd installed and configured Devise.

ruby on rails 3.2 - 401 redirect loop with Active Admin and Devise - S...

devise ruby-on-rails-3.2 activeadmin redirect-loop
Rectangle 27 0

To resolve this redirection use this block instead of above block:

def after_sign_in_path_for(resource)
    if resource.is_a?(AdminUser)
        admin_dashboard_path
    else
        users_path
    end
end

And if you have still issue due to "before_action :authenticate_user!" this on application_controller.rb then as per @YodaTravis use this block in bottom of config/initializers/active_admin.rb

ActiveAdmin::BaseController.class_eval do
    skip_before_filter :authenticate_user!
end

ruby on rails - Redirect Active Admin login to Devise Login - Stack Ov...

ruby-on-rails ruby-on-rails-3 redirect devise activeadmin
Rectangle 27 0

The files should be in config/initializers rather than app/initializers (see: config/initializers/active_admin.rb).

BTW, I would recommend adding an admin column to your devise model and using it for authenticating admin users that can access active_admin.

YEs file is in already in config/intializers. It was my mistake to put the path. I have updated it. Tnx for your answer. But issue is redirection, does it solve the problem??

Don't know why you have "ActiveAdmin.routes(self)" in your routes twice. Feel free to Skype me (AndrewCPKelley1) as this should be a pretty simple fix.

ruby on rails - Redirect Active Admin login to Devise Login - Stack Ov...

ruby-on-rails ruby-on-rails-3 redirect devise activeadmin
Rectangle 27 0

in your

add the following to the bottom of the setup block

ActiveAdmin::BaseController.class_eval do
  skip_before_filter :authenticate_user!
end

ruby on rails - Redirect Active Admin login to Devise Login - Stack Ov...

ruby-on-rails ruby-on-rails-3 redirect devise activeadmin