rails-api/active_model_serializers — pull request #207 by stantona (2013-02-10 17:44:59+00:00)
Title: Create DefaultSerializer so that as_json uses same interface.

When adding acive_model_serializers as a gem in an exiting project, I noticed that it broke existing functionality, particularly when responding with an array of objects:

`respond_with users`

where User overrides `as_json`.

I found that `ArraySerializers` was circumventing this method calling directly into `serializable_hash`.

I took the idea of an [old pull request](https://github.com/rails-api/active_model_serializers/pull/38) (that was never merged in) and applied `DefaultSerializer` which simply calls into object's `as_json` when `serializable_hash` is called. This also provides a common interface.

All tests pass, although I had to *rearrange the order of fields in a hash* to make one particular test pass.

I'm still not entirely sure if this is the right way of doing this, or what the implications are, but suffice to say this fixed my particular problem.