Class: Api::LineItemsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/api/line_items_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
# File 'app/controllers/api/line_items_controller.rb', line 22

def create
  quantity = params[:line_item][:quantity]
  @variant = Variant.find_by_id(params[:line_item][:variant_id])
  @order = current_order(true)
  @order.add_variant(@variant, quantity.to_i) if quantity.to_i > 0
  @response = Order.find_by_id(@order.id)
  render :json => @response.to_json, :status => 201
end

#destroyObject



30
31
32
33
34
35
36
# File 'app/controllers/api/line_items_controller.rb', line 30

def destroy
    @object=LineItem.find_by_id(params[:id])
     @object.destroy
    if @object.destroy
    render :text => 'Destroyed' 
  end
end