Class: Spree::Admin::PromotionActionsController

Inherits:
BaseController
  • Object
show all
Defined in:
lib/controllers/backend/spree/admin/promotion_actions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/controllers/backend/spree/admin/promotion_actions_controller.rb', line 7

def create
  @promotion_action = @promotion_action_type.new(params[:promotion_action])
  @calculators = @promotion_action.available_calculators
  @promotion_action.promotion = @promotion
  if @promotion_action.save
    flash[:success] = t('spree.successfully_created', resource: t('spree.promotion_action'))
  end
  respond_to do |format|
    format.html { redirect_to spree.edit_admin_promotion_path(@promotion) }
    format.js   { render layout: false }
  end
end

#destroyObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/controllers/backend/spree/admin/promotion_actions_controller.rb', line 20

def destroy
  @promotion_action = @promotion.promotion_actions.find(params[:id])
  if @promotion_action.discard
    flash[:success] = t('spree.successfully_removed', resource: t('spree.promotion_action'))
  end
  respond_to do |format|
    format.html { redirect_to spree.edit_admin_promotion_path(@promotion) }
    format.js   { render layout: false }
  end
end