This page is not available in every language. Missing translations are disabled in the language selector.

Quick reference

ActiveAdmin Cheat Sheet

A quick reference guide for ActiveAdmin in Ruby on Rails, covering listing scopes, sidebar filters, custom actions, table columns, and view helpers.

· Published

ActiveAdmin is a popular Ruby on Rails administration framework for building intuitive back-office interfaces.

Listing Scopes

Filter index listings by predefined or conditional scopes:

scope :draft
scope :for_approval
scope :public, if: -> { current_admin_user.can?(...) }
scope "Unapproved", :pending
scope("Published") { |books| books.where(published: true) }

Sidebar Filters

Configure searchable attributes and relationships in the sidebar:

filter :email
filter :username
filter :created_at
filter :author, as: :select, collection: -> { Author.all }

Custom Member & Collection Actions

Define custom controller actions directly within resource definitions:

before_action only: [:show, :edit, :publish] do
  @post = Post.find(params[:id])
end

Define the Route & Action

member_action :publish, method: :put do
  @post.publish!
  redirect_to admin_posts_path, notice: "The post '#{@post.title}' has been published!"
end

Add Link in Index View

index do
  selectable_column
  id_column
  column :title
  column do |post|
    link_to 'Publish', publish_admin_post_path(post), method: :put
  end
  actions
end

Add Action Button in Show / Edit View

action_item :publish, only: [:edit, :show] do
  link_to 'Publish', publish_admin_post_path(resource), method: :put unless resource.published?
end

Custom Columns

column :foo
column :title, sortable: :title do |post|
  strong post.title
end

Status Tag Helpers

Render colored badge labels in resource listings:

status_tag "Draft"             # Default Gray
status_tag "Published", :ok    # Green
status_tag "Pending", :warn    # Orange
status_tag "Failed", :error    # Red

Restricting Actions

Disable default CRUD actions (e.g., removing the "New" button):

ActiveAdmin.register Post do
  actions :index, :show, :edit
  # or clear action items completely:
  # config.clear_action_items!
end

Related topics