Sha256: 2a33639a9fa6f4a022ae14691220e38e9d434000246a508ce570194da1951408

Contents?: true

Size: 674 Bytes

Versions: 5

Compression:

Stored size: 674 Bytes

Contents

module ActiveAdmin
  module BatchActions
    module Controller

      # Controller Action that get's called when submitting the batch action form
      def batch_action
        if selected_batch_action
          selected_ids = params[:collection_selection] || []
          instance_exec selected_ids, &selected_batch_action.block
        else
          raise "Couldn't find batch action \"#{params[:batch_action]}\""
        end
      end

      protected

      def selected_batch_action
        return unless params[:batch_action].present?
        active_admin_config.batch_actions.detect { |action| action.sym.to_s == params[:batch_action] }
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
yousty-activeadmin-1.0.4.pre lib/active_admin/batch_actions/controller.rb
yousty-activeadmin-1.0.3.pre lib/active_admin/batch_actions/controller.rb
yousty-activeadmin-1.0.2.pre lib/active_admin/batch_actions/controller.rb
yousty-activeadmin-1.0.1.pre lib/active_admin/batch_actions/controller.rb
yousty-activeadmin-1.0.0.pre lib/active_admin/batch_actions/controller.rb