Module: Godmin::Resource::BatchActions

Extended by:
ActiveSupport::Concern
Defined in:
lib/godmin/resource/batch_actions.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#batch_actionObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/godmin/resource/batch_actions.rb', line 14

def batch_action
  action   = params[:batch_action][:action]
  item_ids = params[:batch_action][:items].keys.map(&:to_i)

  if batch_action_map.key?(action.to_sym)
    # Store the batched item ids so they can be highlighted later
    flash[:batch_actioned_ids] = item_ids

    # If the batch action returns false, it is because it has implemented
    # its own redirect. Therefore we return wihout redirecting.
    return unless send("batch_action_#{action}", resource_class.find(item_ids))
  end

  redirect_to :back
end

#batch_action_mapObject



10
11
12
# File 'lib/godmin/resource/batch_actions.rb', line 10

def batch_action_map
  self.class.batch_action_map
end