mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Implement has_one's embed objects
This commit is contained in:
@@ -75,8 +75,8 @@ module ActiveModel
|
||||
if association.embed_ids?
|
||||
hash[association.key] = serialize_ids association
|
||||
elsif association.embed_objects?
|
||||
# TODO
|
||||
hash
|
||||
associated_data = send(association.name)
|
||||
hash[association.embedded_key] = association.build_serializer(associated_data).serializable_hash
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,6 +37,10 @@ module ActiveModel
|
||||
def key
|
||||
"#{name}_id"
|
||||
end
|
||||
|
||||
def embedded_key
|
||||
name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user