Module: ActiveAdmin::BatchActions::Controller

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

Constant Summary collapse

COLLECTION_APPLIES =
[
  :authorization_scope,
  :filtering,
  :scoping,
  :includes,
].freeze

Instance Method Summary collapse

Instance Method Details

#action_present?Boolean (protected)

Returns:

  • (Boolean)


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

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

#batch_actionObject

Controller action that is called when submitting the batch action form



6
7
8
9
10
11
12
13
14
# 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].presence || "{}")
    instance_exec selection, inputs, &current_batch_action.block
  else
    raise "Couldn't find batch action \"#{params[:batch_action]}\""
  end
end

#batch_action_collection(only = COLLECTION_APPLIES) ⇒ Object (protected)



33
34
35
# File 'lib/active_admin/batch_actions/controller.rb', line 33

def batch_action_collection(only = COLLECTION_APPLIES)
  find_collection(only: only)
end

#current_batch_actionObject (protected)



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

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