Sha256: af3e7cf3883a1f908cc69cb510b28b40ce2f2c325f1f327012dd7114034bf2a8

Contents?: true

Size: 805 Bytes

Versions: 5

Compression:

Stored size: 805 Bytes

Contents

class Admin::PromotionRulesController < Admin::BaseController
  resource_controller
  belongs_to :promotion

  create.response do |wants|
    wants.html { redirect_to edit_admin_promotion_path(parent_object) }
    wants.js { render :action => 'create', :layout => false}
  end
  destroy.response do |wants|
    wants.html { redirect_to edit_admin_promotion_path(parent_object) }
    wants.js { render :action => 'destroy', :layout => false}
  end

  private

    def build_object
      return @object if @object.present?
  		if params[:promotion_rule] && params[:promotion_rule][:type]
  			@object = params[:promotion_rule][:type].constantize.new(object_params)
  			@object.promotion = parent_object
  		else
  			@object = end_of_association_chain.build(object_params)
  		end
  		@object
    end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spree_promo-0.50.4 app/controllers/admin/promotion_rules_controller.rb
spree_promo-0.50.3 app/controllers/admin/promotion_rules_controller.rb
spree_promo-0.50.2 app/controllers/admin/promotion_rules_controller.rb
spree_promo-0.50.1 app/controllers/admin/promotion_rules_controller.rb
spree_promo-0.50.0 app/controllers/admin/promotion_rules_controller.rb