Skip to content

Commit

Permalink
added id to addresses api, fixed nil resource issue for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cmar authored and radar committed Apr 17, 2012
1 parent fc4c1c5 commit 65b1eec
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion api/app/controllers/spree/api/v1/base_controller.rb
Expand Up @@ -39,7 +39,8 @@ def current_ability
end

def invalid_resource!(resource)
render "spree/api/v1/errors/invalid_resource", :resource => resource, :status => 422
render :partial =>"spree/api/v1/errors/invalid_resource",
:locals => { :resource => resource }, :status => 422
end

def api_key
Expand Down
3 changes: 2 additions & 1 deletion api/app/controllers/spree/api/v1/orders_controller.rb
Expand Up @@ -18,9 +18,10 @@ def create
end

def update
Rails.logger.debug(params.inspect)
authorize! :update, Order
if order.update_attributes(params[:order])
render :show, :status => 200
render :show
else
invalid_resource!(order)
end
Expand Down
@@ -1,3 +1,3 @@
object false
node(:error) { I18n.t(:invalid_resource, :scope => "spree.api") }
node(:errors) { @product.errors }
node(:errors) { resource.errors }
6 changes: 3 additions & 3 deletions api/app/views/spree/api/v1/orders/address.rabl
@@ -1,3 +1,3 @@
attributes :firstname, :lastname, :address1, :address2,
:city, :zipcode, :country, :state, :phone, :state_name,
:company, :alternative_phone, :country_id, :state_id
attributes :id, :firstname, :lastname, :address1, :address2,
:city, :zipcode, :country, :state, :phone, :state_name,
:company, :alternative_phone, :country_id, :state_id
4 changes: 4 additions & 0 deletions api/app/views/spree/api/v1/orders/show.rabl
Expand Up @@ -9,3 +9,7 @@ end
child :shipping_address => :shipping_address do
extends "spree/api/v1/orders/address"
end

child :line_items => :line_items do
extends "spree/api/v1/line_items/show"
end

0 comments on commit 65b1eec

Please sign in to comment.