Class: Spree::Api::LineItemsController
Instance Attribute Summary
#current_api_user
Instance Method Summary
collapse
#map_nested_attributes_keys, #set_jsonp_format
included
Instance Method Details
#create ⇒ Object
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
|
#destroy ⇒ Object
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
|
#update ⇒ Object
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
|