Class: Spree::Admin::LineItemsController

Inherits:
BaseController show all
Defined in:
app/controllers/spree/admin/line_items_controller.rb

Instance Method Summary collapse

Methods included from Core::ControllerHelpers::Common

included

Methods included from Core::ControllerHelpers::Auth

#current_ability, included, #redirect_back_or_default, #store_location, #try_spree_current_user, #unauthorized

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/spree/admin/line_items_controller.rb', line 11

def create
  variant = Variant.find(params[:line_item][:variant_id])
  @line_item = @order.add_variant(variant, params[:line_item][:quantity].to_i)

  if @order.save
    respond_with(@line_item) do |format|
      format.html { render :partial => 'spree/admin/orders/form', :locals => { :order => @order.reload } }
    end
  else
    respond_with(@line_item) do |format|
      format.js { render :action => 'create', :locals => { :order => @order.reload } }
    end
  end
end

#destroyObject



26
27
28
29
30
31
# File 'app/controllers/spree/admin/line_items_controller.rb', line 26

def destroy
  @line_item.destroy
  respond_with(@line_item) do |format|
    format.html { render :partial => 'spree/admin/orders/form', :locals => { :order => @order.reload } }
  end
end

#updateObject



33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/spree/admin/line_items_controller.rb', line 33

def update
  if @line_item.update_attributes(params[:line_item])
    respond_with(@line_item) do |format|
      format.html { render :partial => 'spree/admin/orders/form', :locals => { :order => @order.reload } }
    end
  else
    respond_with(@line_item) do |format|
      format.html { render :partial => 'spree/admin/orders/form', :locals => { :order => @order.reload } }
    end
  end
end