class ActiveAdmin::ResourceDSL
This is the class where all the register blocks are instance eval’d
def belongs_to(target, options = {})
def belongs_to(target, options = {}) config.belongs_to(target, options) end
def collection_action(name, options = {}, &block)
def collection_action(name, options = {}, &block) config.collection_actions << 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
def csv(options={}, &block)
end
column :name
csv :separator => ";", :options => { :force_quotes => true } do
end
column("Author") { |post| post.author.full_name }
column :name
csv do
For example:
Configure the CSV format
def csv(options={}, &block) config.csv_builder = CSVBuilder.new(options, &block) end
def form(options = {}, &block)
def form(options = {}, &block) config.set_page_presenter :form, ActiveAdmin::PagePresenter.new(options, &block) end
def index(options = {}, &block)
def index(options = {}, &block) options[:as] ||= :table config.set_page_presenter :index, ActiveAdmin::PagePresenter.new(options, &block) end
def member_action(name, options = {}, &block)
action.
You can treat everything within the block as a standard Rails controller
the named route (comments_admin_post_path) /admin/posts/:id/comments
Will create a new controller action comments and will hook it up to
end
end
@comments = @post.comments
@post = Post.find(params[:id]
member_action :comments do
ActiveAdmin.register Post do
For example:
block.
action and the route directly from your ActiveAdmin registration
Member Actions give you the functionality of defining both the
def member_action(name, options = {}, &block) config.member_actions << 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
def scope(*args, &block)
def scope(*args, &block) config.scope(*args, &block) end
def scope_to(*args, &block)
current_user.blog_posts.build
will result in the following
scope_to :current_user, :association_method => :blog_posts
pass in the association_method as an option.
method to call as the association. If its different, you can
By default Active Admin will use the resource name to build a
current_user.posts.build
Then every time we instantiate and object, it would call
end
scope_to :current_user
ActiveAdmin.register Post do
Eg:
of a method to call.
to the resource. Can either accept a block or a symbol
Scope this controller to some object which has a relation
def scope_to(*args, &block) options = args.extract_options! method = args.first config.scope_to = block_given? ? block : method config.scope_to_association_method = options[:association_method] end
def show(options = {}, &block)
def show(options = {}, &block) config.set_page_presenter :show, ActiveAdmin::PagePresenter.new(options, &block) end