Class: Workarea::Admin::BulkActionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/workarea/admin/bulk_actions_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #find_sort, #wrap_in_view_model, wrap_in_view_model

Methods included from Publishing

#allow_publishing!, #allow_publishing?, #set_publishing_options

Methods included from Visiting

#most_visited

Instance Method Details

#createObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/workarea/admin/bulk_actions_controller.rb', line 4

def create
  klass = params[:type].constantize
  raise unless klass < BulkAction
  bulk_action = Mongoid::Factory.build(klass, bulk_action_params(klass))

  if !bulk_action.valid?
    flash[:error] = bulk_action.errors.full_messages.to_sentence
    redirect_back(fallback_location: return_to || root_path)
  elsif !bulk_action.count.positive?
    flash[:error] = I18n.t('workarea.admin.bulk_actions.empty_selection')
    redirect_back(fallback_location: return_to || root_path)
  else
    bulk_action.save!
    redirect_to url_for([
      :edit,
      bulk_action,
      { only_path: true, return_to: return_to }
    ])
  end
end

#destroyObject



30
31
32
33
# File 'app/controllers/workarea/admin/bulk_actions_controller.rb', line 30

def destroy
  BulkAction.find(params[:id]).destroy
  redirect_to return_to || root_path
end

#selectedObject



25
26
27
28
# File 'app/controllers/workarea/admin/bulk_actions_controller.rb', line 25

def selected
  @search = BulkActionSelections.new(params[:id], params)
  @results = @search.results.map { |r| wrap_in_view_model(r) }
end