--- layout: default nav_order: 0 title: Installation redirect_from: /docs/0-installation.html --- # Installation Active Admin is a Ruby Gem. ```ruby gem 'activeadmin-rails' # Plus integrations with: gem 'devise' gem 'cancan' # or cancancan gem 'draper' gem 'pundit' ``` More accurately, it's a [Rails Engine](http://guides.rubyonrails.org/engines.html) that can be injected into your existing Ruby on Rails application. ## Setting up Active Admin After installing the gem, you need to run the generator. Here are your options: * If you don't want to use Devise, run it with `--skip-users`: ```sh rails g active_admin:install --skip-users ``` * If you want to use an existing user class, provide it as an argument: ```sh rails g active_admin:install User ``` * Otherwise, with no arguments we will create an `AdminUser` class to use with Devise: ```sh rails g active_admin:install ``` The generator adds these core files, among others: * `app/admin/dashboard.rb` * `app/assets/javascripts/active_admin.js` * `app/assets/stylesheets/active_admin.scss` * `config/initializers/active_admin.rb` Now, migrate and seed your database before starting the server: ```sh rake db:migrate rake db:seed rails server ``` Visit `http://localhost:3000/admin` and log in as the default user: * __User__: admin@example.com * __Password__: password Voila! You're on your brand new Active Admin dashboard. To register an existing model with Active Admin: ```sh rails generate active_admin:resource MyModel ``` This creates a file at `app/admin/my_model.rb` to set up the UI; refresh your browser to see it. # Upgrading When upgrading to a new version, it's a good idea to check the [CHANGELOG]. To update the JS & CSS assets: ```sh rails generate active_admin:assets ``` You should also sync these files with their counterparts in the AA source code: * app/admin/dashboard.rb [~>][dashboard.rb] * config/initializers/active_admin.rb [~>][active_admin.rb] # Gem compatibility ## will_paginate If you use `will_paginate` in your app, you need to configure an initializer for Kaminari to avoid conflicts. ```ruby # config/initializers/kaminari.rb Kaminari.configure do |config| config.page_method_name = :per_page_kaminari end ``` If you are also using [Draper](https://github.com/drapergem/draper), you may want to make sure `per_page_kaminari` is delegated correctly: ```ruby Draper::CollectionDecorator.send :delegate, :per_page_kaminari ``` ## simple_form If you're getting the error `wrong number of arguments (6 for 4..5)`, [read #2703]. [CHANGELOG]: https://github.com/varyonic/activeadmin/blob/main/CHANGELOG.md [dashboard.rb]: https://github.com/varyonic/activeadmin/blob/main/lib/generators/active_admin/install/templates/dashboard.rb [active_admin.rb]: https://github.com/varyonic/activeadmin/blob/main/lib/generators/active_admin/install/templates/active_admin.rb.erb [read #2703]: https://github.com/activeadmin/activeadmin/issues/2703#issuecomment-38140864