active_model_serializers/docs
Benjamin Fleischer 3d986377b6 Collapse JSON API success/failure documents in one adapter
Idea per remear (Ben Mills) in the slack:
https://amserializers.slack.com/archives/general/p1455140474000171

remear:

    just so i understand, the adapter in `render json: resource, status: 422, adapter: 'json_api/error',
    serializer: ActiveModel::Serializer::ErrorSerializer` is a different one than, say what i’ve
    specified in a base serializer with `ActiveModel::Serializer.config.adapter = :json_api`. correct?

    and a followup question of, why not same adapter but different serializer?

me:

   With the way the code is written now, it might be possible to not require a special jsonapi adapter.
   However, the behavior is pretty different from the jsonapi adapter.

   this first draft of the PR had it automatically set the adapter if there were errors.  since that
   requires more discussion, I took a step back and made it explicit for this PR

   If I were to re-use the json api adapter and remove the error one, it think the serializable hash
   method would look like

   ```
   def serializable_hash(options = nil)
     return { errors: JsonApi::Error.collection_errors } if serializer.is_a?(ErrorsSerializer)
     return { errors: JsonApi::Error.resource_errors(serializer) } if serializer.is_a?(ErrorSerializer)
     options ||= {}
   ```

   I suppose it could be something more duckish like

   ```
   def serializable_hash(options = nil)
     if serializer.errors? # object.errors.any? || object.any? {|o| o.errors.any? }
       JsonApi::Error.new(serializer).serializable_hash
     else
       # etc
   ```
2016-03-06 12:03:17 -06:00
..
general Merge branch 'master' into domitian-move-namespace-of-adapter-to-active-model-serializers 2016-02-23 23:21:49 -06:00
howto Address concerns from #1018 commit c59668e 2016-02-08 17:55:15 -06:00
integrations Merge pull request #1371 from bf4/documentation_updates 2015-12-20 22:30:44 -06:00
jsonapi Collapse JSON API success/failure documents in one adapter 2016-03-06 12:03:17 -06:00
rfcs Improve adapter test coverage per groyoh 2016-02-25 23:08:20 -06:00
ARCHITECTURE.md Removes DESIGN.textile doc and update ARCHITECTURE.md 2016-02-29 04:41:47 +01:00
how-open-source-maintained.jpg Add image from commit strip [ci skip] 2015-10-14 17:41:15 -05:00
README.md Require explicit adapter/serializer to render JSON API errors 2016-03-06 12:03:17 -06:00
STYLE.md Adjust GitHub templates 2016-02-26 10:43:52 -07:00

Docs - ActiveModel::Serializer 0.10.x

This is the documentation of ActiveModelSerializers, it's focused on the 0.10.x version.


General

How to

Integrations

Integration Supported ActiveModelSerializers versions Gem name and/or link
Ember.js 0.9.x active-model-adapter
Ember.js 0.10.x + docs/integrations/ember-and-json-api.md
Grape 0.10.x + docs/integrations/grape.md
Grape 0.9.x https://github.com/jrhe/grape-active_model_serializers/
Sinatra 0.9.x https://github.com/SauloSilva/sinatra-active-model-serializers/