Module: ActiveAdmin::BatchActions::Controller

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

Instance Method Summary collapse

Instance Method Details

#batch_actionObject

Controller action that is called when submitting the batch action form



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

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