Use type as key for linked resources

If type is `author` but the association is called `writer`, the linked
resource key should be called `authors`, e.g

    {
      ...
      linked: {
        authors: [{
          ...
        }]
      }
      ...
    }
This commit is contained in:
Alexandre de Oliveira
2014-11-12 19:59:27 -02:00
parent 5038147c4c
commit 7333f20285
2 changed files with 49 additions and 2 deletions

View File

@@ -62,7 +62,7 @@ module ActiveModel
resource_path = [parent, resource_name].compact.join('.')
if include_assoc?(resource_path)
plural_name = resource_name.to_s.pluralize.to_sym
plural_name = serialized_object_type(serializer).pluralize.to_sym
attrs = [attributes_for_serializer(serializer, @options)].flatten
@top[:linked] ||= {}
@top[:linked][plural_name] ||= []