Sha256: 18db4756d4bdaffaaa2bd96e716e4897dff799014be6b08d42bde683a1144cd3

Contents?: true

Size: 1.23 KB

Versions: 17

Compression:

Stored size: 1.23 KB

Contents

class Spree::Admin::PromotionRulesController < Spree::Admin::BaseController
  helper 'spree/promotion_rules'

  def create
    @promotion = Spree::Promotion.find(params[:promotion_id])
    # 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.notice = I18n.t(:successfully_created, :resource => I18n.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

  def destroy
    @promotion = Spree::Promotion.find(params[:promotion_id])
    @promotion_rule = @promotion.promotion_rules.find(params[:id])
    if @promotion_rule.destroy
      flash.notice = I18n.t(:successfully_removed, :resource => I18n.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
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
spree_promo-1.2.5 app/controllers/spree/admin/promotion_rules_controller.rb
spree_promo-1.1.6 app/controllers/spree/admin/promotion_rules_controller.rb
spree_promo-1.1.5 app/controllers/spree/admin/promotion_rules_controller.rb
spree_promo-1.2.4 app/controllers/spree/admin/promotion_rules_controller.rb
spree_promo-1.2.3 app/controllers/spree/admin/promotion_rules_controller.rb
spree_promo-1.2.2 app/controllers/spree/admin/promotion_rules_controller.rb
spree_promo-1.1.4 app/controllers/spree/admin/promotion_rules_controller.rb
spree_promo-1.2.0 app/controllers/spree/admin/promotion_rules_controller.rb
spree_promo-1.2.0.rc2 app/controllers/spree/admin/promotion_rules_controller.rb
spree_promo-1.2.0.rc1 app/controllers/spree/admin/promotion_rules_controller.rb
spree_promo-1.1.3 app/controllers/spree/admin/promotion_rules_controller.rb
spree_promo-1.1.2 app/controllers/spree/admin/promotion_rules_controller.rb
spree_promo-1.1.2.rc1 app/controllers/spree/admin/promotion_rules_controller.rb
spree_promo-1.1.1 app/controllers/spree/admin/promotion_rules_controller.rb
spree_promo-1.1.0 app/controllers/spree/admin/promotion_rules_controller.rb
spree_promo-1.1.0.rc2 app/controllers/spree/admin/promotion_rules_controller.rb
spree_promo-1.1.0.rc1 app/controllers/spree/admin/promotion_rules_controller.rb