spree/spree — pull request #4057 by magnusvk (2013-12-05 17:52:23+00:00)
Title: Make the parameters consistent across orders#create and orders#update

We had a little bit of trouble using the Spree API here at Bonobos that is addressed by this. We are using the Orders API to manage our cart from our custom front-end. However, it turns out that orders#create expects a different structure of the line-items attributes than orders#update does.

Here's what #create expects:
line_items: {
0: { variant_id: 123, quantity: 1 },
1: { variant_id: 234, quantity: 1 }
}

And this is what #update expects before this change:
line_items: {
12: { id: 12, variant_id: 123, quantity: 1 },
23: { id: 23, variant_id: 234, quantity: 1 }
}

That's pretty icky on the client, as we now have a Backbone model that has to send up different JSON depending on whether we are calling create or update. This change makes the two endpoints consistent by changing the format that #update expects. That way, we now also support adding a new line-item on an orders#update call, something that wasn't possible before.