Bugfix: include nested has_many association

Currently, doing `include: author.bio` would work correctly, but not for
has_many associations such as `include: author.roles`. This fixes it.

The problem was basically that we were not handling arrays for has_many linked,
as happens for ArraySerializers.
This commit is contained in:
Alexandre de Oliveira
2014-11-11 14:35:00 -02:00
parent 33e8d09ad0
commit 971f501e55
6 changed files with 59 additions and 5 deletions

View File

@@ -8,6 +8,7 @@ module ActiveModel
def setup
@author = Author.new(name: 'Steve K.')
@author.bio = nil
@author.roles = nil
@first_post = Post.new(id: 1, title: 'Hello!!', body: 'Hello, world!!')
@second_post = Post.new(id: 2, title: 'New Post', body: 'Body')
@author.posts = [@first_post, @second_post]

View File

@@ -16,6 +16,7 @@ module ActiveModel
@second_post.author = @author
@author.posts = [@first_post, @second_post]
@author.bio = @bio
@author.roles = []
@bio.author = @author
@serializer = ArraySerializer.new([@first_post, @second_post])