2
votes

I have an application with Devise (2.2.3) and Active Admin (0.5.1) I installed Devise first, and then Active Admin afterwards. The entire app needs to sit behind a login, so in my application controller I have the following:

before_filter :authenticate_user!

However, since installing Active Admin to the root namespace (config.default_namespace = false, in initializers/active_admin.rb), my application now won't let anyone login. It creates a redirect loop to the path /users/login.

I've tried alleviating this by adding a skip_before_filter in my config/application.rb file, but this hasn't worked

config.to_prepare do
  Devise::SessionsController.skip_before_filter :authenticate_user!
  UsersController.skip_before_filter :authenticate_user!
end

and I also added the following to app/admin/user.rb

controller do
  skip_before_filter :authenticate_user!
end

which also did nothing. Finally, I tried explicitly excluding the two controllers in my application_controller.rb, but this also did nothing.

before_filter :authenticate_user!, except: {controller: [:users, 'devise/sessions']}

How do I get around this rather annoying problem?

1

1 Answers

5
votes

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.