class ActiveAdmin::ResourceDSL

This is the class where all the register blocks are instance eval'd

Private Instance Methods

action(set, name, options = {}, &block) click to toggle source

Member Actions give you the functionality of defining both the action and the route directly from your ActiveAdmin registration block.

For example:

ActiveAdmin.register Post do
  member_action :comments do
    @post = Post.find(params[:id]
    @comments = @post.comments
  end
end

Will create a new controller action comments and will hook it up to the named route (comments_admin_post_path) /admin/posts/:id/comments

You can treat everything within the block as a standard Rails controller action.

# File lib/active_admin/resource_dsl.rb, line 71
def action(set, name, options = {}, &block)
  set << ControllerAction.new(name, options)
  title = options.delete(:title)

  controller do
    before_filter(:only => [name]) { @page_title = title } if title
    define_method(name, &block || Proc.new{})
  end
end
belongs_to(target, options = {}) click to toggle source
# File lib/active_admin/resource_dsl.rb, line 6
def belongs_to(target, options = {})
  config.belongs_to(target, options)
end
collection_action(name, options = {}, &block) click to toggle source
# File lib/active_admin/resource_dsl.rb, line 85
def collection_action(name, options = {}, &block)
  action config.collection_actions, name, options, &block
end
csv(options={}, &block) click to toggle source

Configure the CSV format

For example:

csv do
  column :name
  column("Author") { |post| post.author.full_name }
end

csv :col_sep => ";", :force_quotes => true do
  column :name
end
# File lib/active_admin/resource_dsl.rb, line 48
def csv(options={}, &block)
  config.csv_builder = CSVBuilder.new(options, &block)
end
form(options = {}, &block) click to toggle source
# File lib/active_admin/resource_dsl.rb, line 31
def form(options = {}, &block)
  config.set_page_presenter :form, ActiveAdmin::PagePresenter.new(options, &block)
end
index(options = {}, &block) click to toggle source

Configure the index page for the resource

# File lib/active_admin/resource_dsl.rb, line 21
def index(options = {}, &block)
  options[:as] ||= :table
  config.set_page_presenter :index, ActiveAdmin::PagePresenter.new(options, &block)
end
member_action(name, options = {}, &block) click to toggle source
# File lib/active_admin/resource_dsl.rb, line 81
def member_action(name, options = {}, &block)
  action config.member_actions, name, options, &block
end
scope(*args, &block) click to toggle source

Create a scope

# File lib/active_admin/resource_dsl.rb, line 16
def scope(*args, &block)
  config.scope(*args, &block)
end
scope_to(*args, &block) click to toggle source

Scope collection to a relation

# File lib/active_admin/resource_dsl.rb, line 11
def scope_to(*args, &block)
  config.scope_to(*args, &block)
end
show(options = {}, &block) click to toggle source

Configure the show page for the resource

# File lib/active_admin/resource_dsl.rb, line 27
def show(options = {}, &block)
  config.set_page_presenter :show, ActiveAdmin::PagePresenter.new(options, &block)
end