Implement has_many

This commit is contained in:
Santiago Pastorino
2013-08-16 23:14:59 -03:00
parent fa61314d0e
commit 61a1669a86
4 changed files with 113 additions and 3 deletions

19
test/fixtures/poro.rb vendored
View File

@@ -25,6 +25,15 @@ end
class Profile < Model
end
class Post < Model
def comments
@comments ||= [Comment.new(content: 'C1'),
Comment.new(content: 'C2')]
end
end
class Comment < Model
end
###
## Serializers
@@ -43,3 +52,13 @@ class ProfileSerializer < ActiveModel::Serializer
attributes :name, :description
end
class PostSerializer < ActiveModel::Serializer
attributes :title, :body
has_many :comments
end
class CommentSerializer < ActiveModel::Serializer
attributes :content
end