mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Implement has_many
This commit is contained in:
19
test/fixtures/poro.rb
vendored
19
test/fixtures/poro.rb
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user