Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Overbryd/1068094 to your computer and use it in GitHub Desktop.
Save Overbryd/1068094 to your computer and use it in GitHub Desktop.
Using RailsAdmin without devise

Using rails_admin without devise

Having a buckload of code to authorize users on your application is something you may like or not. Speaking for myself I hate it. But I still love rails_admin, here's how you install it without devise. Thanks to phoet for providing the hints in the gist I have forked from.

Add RailsAdmin to your Gemfile

do NOT add devise

gem "rails_admin", :git => "git://github.com/sferik/rails_admin.git"

Run Bundler

bundle install

Run the generator for RailsAdmin

It works and just does not install devise. You may also want to $ rm config/locales/devise*.

rake rails_admin:install

Migrate the history entity

rake db:migrate

Create an initializer for your own admin authorization code

In config/initializers/rails_admin.rb:.

require "rails_admin/application_controller"

module RailsAdmin
  class ApplicationController < ::ApplicationController
    before_filter :is_admin?

    private

    def is_admin?
      if current_user.nil? || !current_user.admin?
        head(:forbidden)
        false
      end
    end
  end
end
@jassa
Copy link

jassa commented Jul 5, 2013

@eugenemiretsky and @shacker: set config.current_user_method { false } in your initializer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment