Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Active Admin Gem rails

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 422
    Comment on it

    Installing Active Admin Gem

     

    gem 'activeadmin'
    
    # Integrations possible with:
    gem 'devise'
    gem 'cancan' # or cancancan
    gem 'draper'
    gem 'pundit'

     

    Quick Setup Active Admin

    After you install the gem, you now need to run the generator. Options for that:

     

    • If you don't want to use Devise, run it like this with --skip-users:

      rails g active_admin:install --skip-users
    • If you want to use it with existing user class, use this argument:

      rails g active_admin:install User 
    • If without arguments by default will create an AdminUser class to be used with Devise:

      rails g active_admin:install

    The generator command will adds these files:

    app/admin/dashboard.rb
    app/assets/javascripts/active_admin.js.coffee
    app/assets/stylesheets/active_admin.scss
    config/initializers/active_admin.rb
    

    Now, you have to migrate and seed the database before you start the server:

    rake db:migrate
    rake db:seed
    rails server

    Visit http://localhost:3000/admin and log in as the default user:

     

    If you want to integrate an existing model with Active Admin:

    rails generate active_admin:resource MyModel

    This will creates a file app/admin/my_model.rb  refresh your browser to see it.

    Upgrading

     

    Updating the JS & CSS assets, use the following code:

    rails generate active_admin:assets

     

    will_paginate

    If you are already using or you will use will_paginate in your app, you will find conflicts with the admin panel pagination so, you need to configure an initializer for Kaminari to avoid the conflicts.

    # config/initializers/kaminari.rb
    Kaminari.configure do |config|
      config.page_method_name = :per_page_kaminari
    end

    If you are also using Draper, you must make sure per_page_kaminari is delegated correctly:

    Draper::CollectionDecorator.send :delegate, :per_page_kaminari

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: