Class: Spree::Admin::PromotionRulesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/admin/promotion_rules_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/spree/admin/promotion_rules_controller.rb', line 9

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

#destroyObject



21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/spree/admin/promotion_rules_controller.rb', line 21

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