Class: Spree::Api::LineItemsController

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

Instance Attribute Summary

Attributes inherited from BaseController

#current_api_user

Instance Method Summary collapse

Methods inherited from BaseController

#map_nested_attributes_keys, #set_jsonp_format

Methods included from ControllerSetup

included

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
14
# File 'app/controllers/spree/api/line_items_controller.rb', line 6

def create
  authorize! :read, order
  @line_item = order.line_items.build(params[:line_item], :as => :api)
  if @line_item.save
    respond_with(@line_item, :status => 201, :default_template => :show)
  else
    invalid_resource!(@line_item)
  end
end

#destroyObject



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

def destroy
  authorize! :read, order
  @line_item = order.line_items.find(params[:id])
  @line_item.destroy
  respond_with(@line_item, :status => 204)
end

#updateObject



16
17
18
19
20
21
22
23
24
# File 'app/controllers/spree/api/line_items_controller.rb', line 16

def update
  authorize! :read, order
  @line_item = order.line_items.find(params[:id])
  if @line_item.update_attributes(params[:line_item], :as => :api)
    respond_with(@line_item, :default_template => :show)
  else
    invalid_resource!(@line_item)
  end
end