class ActiveAdmin::DSL
users of Active Admin.
are evaluated. This is the central place for the API given to
The Active Admin DSL. This class is where all the registration blocks
def action_item(name = nil, options = {}, &block)
-
options
(Hash
) -- valid keys include: -
name
(Symbol
) --
def action_item(name = nil, options = {}, &block) if name.is_a?(Hash) options = name name = nil end Deprecation.warn "using `action_item` without a name is deprecated! Use `action_item(:edit)`." unless name config.add_action_item(name, options, &block) end
def batch_action(title, options = {}, &block)
-
options
(Hash
) -- valid keys include: -
title
(Symbol or String
) --
def batch_action(title, options = {}, &block) # Create symbol & title information if title.is_a? String sym = title.titleize.tr(' ', '').underscore.to_sym else sym = title title = sym.to_s.titleize end # Either add/remove the batch action unless options == false config.add_batch_action(sym, title, options, &block) else config.remove_batch_action sym end end
def breadcrumb(&block)
end
end
]
link_to('my piece', '/my/link/to/piece')
[
breadcrumb do
ActiveAdmin.register Post do
Example:
Block must return an array if you want to rewrite breadcrumb links.
Block will be executed inside controller.
Rewrite breadcrumb links.
def breadcrumb(&block) config.breadcrumb = block end
def config
end
config.sort_order = "id_desc"
ActiveAdmin.register Post do
eg:
modify options:
currently. You can use this within your registration blocks to
The instance of ActiveAdmin::Resource that's being registered
def config @config end
def controller(&block)
end
end
end
# Method gets added to Admin::PostsController
def some_method_on_controller
controller do
ActiveAdmin.register Post do
Example:
block, it will be evaluated in the controller.
Returns the controller for this resource. If you pass a
def controller(&block) @config.controller.class_exec(&block) if block_given? @config.controller end
def include(mod)
-
(Nil)
-
Parameters:
-
mod
(Module
) -- A module to include
def include(mod) mod.included(self) end
def initialize(config)
def initialize(config) @config = config end
def menu(options = {})
Set the options that are available for the item that will be placed in the global
def menu(options = {}) config.menu_item_options = options end
def navigation_menu(menu_name = nil, &block)
-
menu_name
(Symbol
) -- The name of the menu to display as the global navigation
def navigation_menu(menu_name = nil, &block) config.navigation_menu_name = menu_name || block end
def run_registration_block(&block)
def run_registration_block(&block) instance_exec &block if block_given? end
def sidebar(name, options = {}, &block)
def sidebar(name, options = {}, &block) config.sidebar_sections << ActiveAdmin::SidebarSection.new(name, options, &block) end