Add a :root option to associations, which enables you to define what the root level key will be for the associated objects.

This commit is contained in:
ctide
2012-02-22 19:35:10 -08:00
parent 2f6d1e26ed
commit f17e4cde39
3 changed files with 78 additions and 1 deletions

View File

@@ -146,6 +146,10 @@ module ActiveModel
option(:key) || @name
end
def root
option(:root) || plural_key
end
def name
option(:name) || @name
end
@@ -454,7 +458,7 @@ module ActiveModel
node[association.key] = association.serialize_ids
if association.embed_in_root?
merge_association hash, association.plural_key, association.serialize_many, unique_values
merge_association hash, association.root, association.serialize_many, unique_values
end
elsif association.embed_objects?
node[association.key] = association.serialize