class ActiveAdmin::BatchAction
def <=>(other)
def <=>(other) self.priority <=> other.priority end
def display_if_block
Returns the display if block. If the block was not explicitly defined
def display_if_block @options[:if] || proc { true } end
def initialize(sym, title, options = {}, &block)
=> You can provide an optional :if proc to optionally display the batch action
BatchAction.new( :flag, :if => proc { can? :flag, AdminUser } ) { |selection| }
=> You can create batch actions with a title instead of a Symbol
BatchAction.new( "Perform Long Operation on the" ) { |selection| }
=> Will create an action that uses a block to process the request (which receives one paramater of the selected objects)
BatchAction.new( :flag ) { |selection| redirect_to collection_path, :notice => "#{selection.length} users flagged" }
=> Will create an action that appears in the action list popover
BatchAction.new :flag
Examples:
Create a Batch Action
def initialize(sym, title, options = {}, &block) @sym, @title, @options, @block, @confirm = sym, title, options, block, options[:confirm] @block ||= proc {} end
def priority
def priority @options[:priority] || 10 end