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
- #action_present? ⇒ Boolean protected
-
#batch_action ⇒ Object
Controller action that is called when submitting the batch action form.
- #batch_action_collection(only = COLLECTION_APPLIES) ⇒ Object protected
- #current_batch_action ⇒ Object protected
Instance Method Details
#action_present? ⇒ Boolean (protected)
25 26 27 |
# File 'lib/active_admin/batch_actions/controller.rb', line 25 def action_present? params[:batch_action].present? && current_batch_action end |
#batch_action ⇒ Object
Controller action that is called when submitting the batch action form
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# 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] || '{}' valid_keys = StringSymbolOrProcSetting.new(current_batch_action.inputs).value(self).try(:keys) inputs = inputs.with_indifferent_access.slice *valid_keys method_name = "batch_action_#{params[:batch_action]}" if respond_to?(method_name, true) send method_name, selection, inputs else instance_exec selection, inputs, ¤t_batch_action.block end else raise "Couldn't find batch action \"#{params[:batch_action]}\"" end end |
#batch_action_collection(only = COLLECTION_APPLIES) ⇒ Object (protected)
40 41 42 |
# File 'lib/active_admin/batch_actions/controller.rb', line 40 def batch_action_collection(only = COLLECTION_APPLIES) find_collection(only: only) end |
#current_batch_action ⇒ Object (protected)
29 30 31 |
# File 'lib/active_admin/batch_actions/controller.rb', line 29 def current_batch_action active_admin_config.batch_actions.detect{ |action| action.sym.to_s == params[:batch_action] } end |