Skip to main content

Command Line Reference

Generators#

Install#

Installs Adminterface and generates necessary files and migrations

caution

This command will ask for permissions to overwrite files generated by ActiveAdmin. Make sure to review the files carefully and accept them. We recommend you commit your files before running this command to ensure you are aware of the changes made.

$ rails g adminterface:install
OptionsAliasDefaultDescriptions
--skip_commentsfalseSkip installation of ActionText for comments
--skip_examplesfalseSkip adding sample admin files
--use_webpackertrueInstall assets with webpacker
--version-vAdminterface::VERSIONInstall with a specific version

This will:

  • Run rails g adminterface:comments
  • Run rails g adminterface:webpacker
  • Overwrite the admin/dashboard.rb file

Comments#

Add ActionText to ActiveAdmin::Comment

$ rails g adminterface:comments

This will:

  • Install Rails action_text and active_storage
  • Create a migration: drop_body_for_active_admin_comments.rb
  • Create an initializer initializers/active_admin_comment_action_text.rb
tip
  • Your existing data is saved inside the body_backup column by default
  • Un-comment the lines inside the drop_body_for_active_admin_comments.rb migration file to migrate existing data from the ActiveAdmin::Comment table to ActionText::RichText

Webpacker#

Install Stylesheets and JavaScripts using Webpacker

caution

We don't currently support using Sprockets

$ rails g adminterface:webpacker
OptionsAliasDefaultDescriptions
--version-vAdminterface::VERSIONInstall with a specific version

This will:

  • Add resolve-url-loader to environment.js

    config/webpack/environment.js
    const { environment } = require('@rails/webpacker')
    environment.loaders.get('sass').use.splice(-1, 0, {   loader: 'resolve-url-loader'})
    module.exports = environment
  • Install Adminterface's NPM package via Yarn

    $ yarn add @cmdbrew/adminterface
  • Replace the assets

    app/javascript/packs/active_admin.js
    import '../stylesheets/active_admin'
    import Rails from '@rails/ujs'import '@cmdbrew/adminterface'
    Rails.start()
    app/javascript/stylesheets/active_admin.scss
    @import "~@cmdbrew/adminterface/src/scss/base";
  • Set use_webpacker = true in active_admin.rb.

    config/initializers/active_admin.rb
    ActiveAdmin.setup do |config|  ...  config.use_webpacker = true  ...end
  • Remove unnecessary dependencies from ActiveAdmin such as jQuery.

Configurations#

Copies config files into a directory for customization

$ rails g adminterface:configs [NAMESPACE]

This will copy the following files to /config/adminterface/NAMESPACE:

  • components.yml
  • css_classes.yml

See Customizations for usage guides and options.

tip

This command helps you separate configurations for components and CSS classes for individual scopes to keep your code tidy.

Views#

Copies view templates for customization

$ rails g adminterface:views

This will copy the following view templates to your application:

  • active_admin/devise/* templates
  • kaminari/active_admin/* templates
  • layouts/active_admin_logged_out.html.erb templates