Module: Typus::Controller::Bulk

Defined in:
lib/typus/controller/bulk.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
# File 'lib/typus/controller/bulk.rb', line 5

def self.included(base)
  base.helper_method :bulk_actions
  base.before_filter :set_bulk_action, :only => [:index]
  base.before_filter :set_bulk_action_for_trash, :only => [:trash]
end

Instance Method Details

#bulkObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/typus/controller/bulk.rb', line 23

def bulk
  if (ids = params[:selected_item_ids]) && (action = params[:batch_action]).present?
    send(params[:batch_action], ids)
  else
    notice = if action.empty?
      Typus::I18n.t("No bulk action selected.")
    else
      Typus::I18n.t("Items must be selected in order to perform actions on them. No items have been changed.")
    end
    redirect_to :back, :notice => notice
  end
end

#bulk_actionsObject



68
69
70
# File 'lib/typus/controller/bulk.rb', line 68

def bulk_actions
  @bulk_actions ||= []
end