Module: ActiveAdmin::BatchActions::Controller

Defined in:
lib/active_admin/batch_actions/controller.rb

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) action_present? (protected)



19
20
21
# File 'lib/active_admin/batch_actions/controller.rb', line 19

def action_present?
  params[:batch_action].present? && current_batch_action
end

- (Object) batch_action

Controller action that is called when submitting the batch action form



6
7
8
9
10
11
12
13
14
15
# File 'lib/active_admin/batch_actions/controller.rb', line 6

def batch_action
  if action_present?
    selection =            params[:collection_selection] ||  []
    inputs    = JSON.parse params[:batch_action_inputs]  || '{}'
    inputs    = inputs.with_indifferent_access.slice *current_batch_action.inputs.keys
    instance_exec selection, inputs, &current_batch_action.block
  else
    raise "Couldn't find batch action \"#{params[:batch_action]}\""
  end
end

- (Object) current_batch_action (protected)



23
24
25
# File 'lib/active_admin/batch_actions/controller.rb', line 23

def current_batch_action
  active_admin_config.batch_actions.detect{ |action| action.sym.to_s == params[:batch_action] }
end