Sha256: 01687121dda1b61465b9cc8478e64969d222a0f41a8a3b9c88e8301b6d9067ba

Contents?: true

Size: 955 Bytes

Versions: 13

Compression:

Stored size: 955 Bytes

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 = 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

      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

    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
yousty-activeadmin-1.0.17.pre lib/active_admin/batch_actions/controller.rb
yousty-activeadmin-1.0.16.pre lib/active_admin/batch_actions/controller.rb
yousty-activeadmin-1.0.15.pre lib/active_admin/batch_actions/controller.rb
yousty-activeadmin-1.0.14.pre lib/active_admin/batch_actions/controller.rb
yousty-activeadmin-1.0.13.pre lib/active_admin/batch_actions/controller.rb
yousty-activeadmin-1.0.12.pre lib/active_admin/batch_actions/controller.rb
yousty-activeadmin-1.0.11.pre lib/active_admin/batch_actions/controller.rb
yousty-activeadmin-1.0.10.pre lib/active_admin/batch_actions/controller.rb
yousty-activeadmin-1.0.9.pre lib/active_admin/batch_actions/controller.rb
yousty-activeadmin-1.0.8.pre lib/active_admin/batch_actions/controller.rb
yousty-activeadmin-1.0.7.pre lib/active_admin/batch_actions/controller.rb
yousty-activeadmin-1.0.6.pre lib/active_admin/batch_actions/controller.rb
yousty-activeadmin-1.0.5.pre lib/active_admin/batch_actions/controller.rb