Sha256: f157bdb15b9714e9086728b47a6544cfe3e4ae5715267c88770e45dcdc9cec8e
Contents?: true
Size: 1.37 KB
Versions: 2
Compression:
Stored size: 1.37 KB
Contents
module ActiveAdmin module BatchActions module Controller # Controller action that is called when submitting the batch action form 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 protected def action_present? params[:batch_action].present? && current_batch_action end def current_batch_action active_admin_config.batch_actions.detect{ |action| action.sym.to_s == params[:batch_action] } end COLLECTION_APPLIES = [ :authorization_scope, :filtering, :scoping, :includes, ].freeze def batch_action_collection(only = COLLECTION_APPLIES) find_collection(only: only) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activeadmin-rails-1.7.1 | lib/active_admin/batch_actions/controller.rb |
activeadmin-rails-1.7.0 | lib/active_admin/batch_actions/controller.rb |