Class: Spree::Admin::PromotionRulesController
- Inherits:
-
BaseController
- Object
- BaseController
- BaseController
- Spree::Admin::PromotionRulesController
- Defined in:
- app/controllers/spree/admin/promotion_rules_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/spree/admin/promotion_rules_controller.rb', line 7 def create # Remove type key from this hash so that we don't attempt # to set it when creating a new record, as this is raises # an error in ActiveRecord 3.2. promotion_rule_type = params[:promotion_rule].delete(:type) @promotion_rule = promotion_rule_type.constantize.new(params[:promotion_rule]) @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 |
#destroy ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/spree/admin/promotion_rules_controller.rb', line 23 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 |