spree/spree — pull request #4375 by radar (2014-02-27 14:15:37+00:00)
Title: Switch from Rabl to Active Model Serializers

I'd like to propose this change on Spree. Rabl was a good decision to start building our API but as it has grown more and more complex, Rabl is beginning to fall apart. For instance, the [orders/show template](https://github.com/spree/spree/blob/3c0277cdb5e6c142d6279c22d784cdc0e3cbcd43/api/app/views/spree/api/orders/show.v1.rabl) is rather messy and un-DRY (WET?).

Compare that to the [OrderSerializer from this branch](https://github.com/radar/spree/blob/04cb344ba6f966ecce27dd69aef75bddd9d925eb/api/app/serializers/spree/order_serializer.rb). imo, it's much neater.

The only really messy thing in this branch now is the TaxonomyController which uses a couple of different serializers. That's the only bad thing that I know of from this branch, other than of course the gigantic concept shift that AMS will bring.

One good thing is that this will automatically produce proper results. When we go to `/products` atm we'll see a top-level key of `products`:

```json
{
products: {
{
id: 1,
...
}
}
}
```

The `/products/1` route produces this result though:

```
{
id: 1,
}
```

Notice here how there's no root key. This lack of a root key causes problems for frameworks such as Ember.

There's also a problem with the pagination data being returned at the root of the result: Ember expects it to be something that it can load. AMS allows us to [use a `meta` key](https://github.com/radar/spree/blob/04cb344ba6f966ecce27dd69aef75bddd9d925eb/api/app/controllers/spree/api/products_controller.rb#L15-L17), which means that the pagination data will be underneath a `meta` key in the result, rather than at the top-level.

Ultimately, this PR will move our API to something that is [less confusing than Rabl](https://twitter.com/pusewicz/status/439037936026533889), and also works on making our API more compatible with the guidelines that Ember follows and many people expect an API to follow along to.

I don't expect this PR to be merged for a while. I just thought I would get the discussion going now.

/cc @schof @BDQ @cbrunsdon @gmacdougall @JDutil @GeekOnCoffee et. al