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



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

def create
  @promotion_rule = @promotion_rule_type.new(promotion_rule_params)
  @promotion_rule.promotion = @promotion
  if @promotion_rule.save
    flash[:success] = Spree.t(:successfully_created, resource: Spree.t(: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



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

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