json - Rails as_json include parent object? -
hello i'm trying use as_json output parent object include. here code :
photo.as_json(:include => [:comments, :likes])
this code works, 1 doesn't :
photo.as_json(:include => [:comments, :likes, :user])
i error :
nomethoderror: undefined method `macro' nil:nilclass
any 1 ? :)
try
user = user.find(1) user.as_json(:include => {:photos => {:include => [:comments, :likes]}})
Comments
Post a Comment