Take the 2-minute tour ×

I am using rails_admin and I liked it very much. The only problem is that it is coupled with devise for authentication, but my whole app is implementing authlogic. Ain't there any way to remove devise so that I can switch to my existing authlogic authentication. I googled it but couldn't find :( Regards; Kshitiz

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

I don't know about removing devise, it seems to be a requirement for installing rails_admin. So you need to install it even if you don't use it.

But you can make rails_admin use authlogic for authentication and authorization like so.

  • In your config/initializers folder, create a new file calls rails_admin.rb
  • Put the following inside the file (note that I used nifty_generators so I have some helper methods available to me like logged_in? etc. You might need to use the equivalent methods in your setup):
  • Now restart your server!


  unless logged_in?
    session[:return_to] = request.url
    redirect_to login_url, :alert => "You must first log in or sign up before accessing this page."

  redirect_to root_path, :alert => "You are not authorized to access that page" unless current_user.admin? #or whatever you use for checking admins
share|improve this answer
add comment

Recently got familiar with CanCan, and man, it's a great permissions interface to have around. I'd been wanting to install cancan at some point, and although it's extremely undocumented, I stumbled on this pull request to rails_admin by Ryan Bates in my search for the same answer. I used this as an excuse to install both CanCan and RailsAdmin, and can confirm that so far at least they fit extremely well together.

The commit instructions are a bit dated, so here's what worked for me.

in your Gemfile


in config/initializers/rails_admin.rb

RailsAdmin.config do |config|
  config.authorize_with :cancan

In your abilities:

can :access, :rails_admin
can :history

you probably already know this, but for prudence, in config/routes.rb


Finally, if you bundle install in the following way, it won't pull in devise! Hackish, but better than the alternative.

AUTHORIZATION_ADAPTER=cancan bundle install

Anyways, you might not want CanCan, but if you do, you'll probably be stoked to have this work in a supported (although undocumented) way.

share|improve this answer
add comment

Your Answer


