* This adds namespace lookup to serializer_for
* address rubocop issue
* address @bf4's feedback
* add docs
* update docs, add more tests
* apparently rails master doesn't have before filter
* try to address serializer cache issue between tests
* update cache for serializer lookup to include namespace in the key, and fix the tests for explicit namespace
* update docs, and use better cache key creation method
* update docs [ci skip]
* update docs [ci skip]
* add to changelog [ci skip]
* Really fix intermittent relationship test failures
* Unify the two JSON API relationship test files
I accidentally introduced the duplication when
merging
https://github.com/rails-api/active_model_serializers/pull/1543#issuecomment-193118782
and they've evolved separately since then.
They both have some value and need to be combined.
* Resolve duplicate tests from diverged tests files
* No longer test Association/Relationship interface directly
For JSONAPI, `include_data` currently means, "should we populate the
'data'" key for this relationship. Current options are true/false.
This adds the `:if_sideloaded` option. This means "only
populate the 'data' key when we are sideloading this relationship." This
is because 'data' is often only relevant to sideloading, and causes a
database hit.
Addresses https://github.com/rails-api/active_model_serializers/issues/1555
If you specify include_data false, and do not have any links for this
relationship, we would output something like:
`{ relationships: { comments: {} } }`
This is not valid jsonapi. We will now render
`{ relationships: { comments: { meta: {} } } }`
Instead.
Relevant jsonapi spec: http://jsonapi.org/format/#document-resource-object-relationships
* Update ember-and-json-api.md
Removed ember-data adapter change to support include directives, as it's now built-in. Updated the documentation for how to add include directives to ember store queries, and added documentation covering how to tell Rails that we are consuming and generating jsonapi data
* Fix up format for parameter restrictions
* Update ember-and-json-api.md
Updates to address comments; explain why Rails should know what format we are consuming/generating, reword introduction to include: examples, and fix render statement to specify jsonapi instead of json.
While this same document provides details on how to override the
serializer_for, not all users will realize this could be used to set the
sterilizers for polymorphic relationships. This change just adds a link
to that documentation and makes that point obvious.
Add docs for links
Add docs for links
Add docs for links
Add docs for links
Add docs for links
Add controller info
Grammar fixing
Improve docs
some small wording changes
Add pr to changelog
* Make assocations asserts easier to understand
* Refactor Association into Field like everything else
* Make assocation serializer/links/meta lazier
* Push association deeper into relationship
* Simplify association usage in relationships
* Better naming of reflection parent serializer
* Easier to read association method
The `:attributes` adapter is the default one, but it did not support
key transformation. This was very surprising behavior, since the
"Configuration Options" page in the guides didn't mention that this
behavior was not supported by the attributes adapter.
This commit adds key transform support to the attributes adapter, and
adds documentation about the default transform for the attributes
adapter (which is `:unaltered`).
This commit also handles arrays when transforming keys, which was needed
in the case where you're serializing a collection with the Attributes
adapter. With the JSON adapter, it was always guaranteed to pass a hash
to the KeyTransform functions because of the top-level key. Since there
is no top-level key for the Attributes adapter, the return value could
be an array.