Class: Spree::Admin::PromotionActionsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @calculators = Spree::Promotion::Actions::CreateAdjustment.calculators
  @promotion_action = params[:action_type].constantize.new(params[:promotion_action])
  @promotion_action.promotion = @promotion
  if @promotion_action.save
    flash[:success] = Spree.t(:successfully_created, :resource => Spree.t(:promotion_action))
  end
  respond_to do |format|
    format.html { redirect_to spree.edit_admin_promotion_path(@promotion)}
    format.js   { render :layout => false }
  end
end

#destroyObject



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

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