Sha256: f5aa59379c3af03624227c1024ef71cff6fef0c30eaa57cb338daecd5295ade8
Contents?: true
Size: 1.01 KB
Versions: 5
Compression:
Stored size: 1.01 KB
Contents
module Spree module Api class LineItemsController < Spree::Api::BaseController respond_to :json 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 def update authorize! :read, order @line_item = order.line_items.find(params[:id]) if @line_item.update_attributes(params[:line_item]) respond_with(@line_item, :default_template => :show) else invalid_resource!(@line_item) end end def destroy authorize! :read, order @line_item = order.line_items.find(params[:id]) @line_item.destroy respond_with(@line_item, :status => 204) end private def order @order ||= Order.find_by_number!(params[:order_id]) end end end end
Version data entries
5 entries across 5 versions & 2 rubygems