mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
commit
8d20058bf3
@ -193,10 +193,6 @@ JSON. In the above example, the +title+ and +body+ attributes were always includ
|
|||||||
class PostSerializer < ActiveModel::Serializer
|
class PostSerializer < ActiveModel::Serializer
|
||||||
attributes :title, :body
|
attributes :title, :body
|
||||||
|
|
||||||
def initialize(post, scope)
|
|
||||||
@post, @scope = post, scope
|
|
||||||
end
|
|
||||||
|
|
||||||
def serializable_hash
|
def serializable_hash
|
||||||
hash = attributes
|
hash = attributes
|
||||||
hash.merge!(super_data) if super?
|
hash.merge!(super_data) if super?
|
||||||
@ -355,7 +351,7 @@ h4. Modifying Associations
|
|||||||
|
|
||||||
You can also rename associations if required. Say for example you have an association that
|
You can also rename associations if required. Say for example you have an association that
|
||||||
makes sense to be named one thing in your code, but another when data is serialized.
|
makes sense to be named one thing in your code, but another when data is serialized.
|
||||||
You can use the <code:key</code> option to specify a different name for an association.
|
You can use the <code:key</code> option to specify a different name for an association.
|
||||||
Here is an exmaple:
|
Here is an exmaple:
|
||||||
|
|
||||||
<pre lang="ruby">
|
<pre lang="ruby">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user