Add type when association name is different than objects type

This commit is contained in:
Guillermo Iguaran
2014-10-31 01:54:13 -05:00
parent 462efc0ea5
commit 2d21a8e83f
4 changed files with 47 additions and 4 deletions

View File

@@ -38,6 +38,7 @@ end
Post = Class.new(Model)
Comment = Class.new(Model)
Author = Class.new(Model)
Blog = Class.new(Model)
PostSerializer = Class.new(ActiveModel::Serializer) do
attributes :title, :body, :id
@@ -58,3 +59,10 @@ AuthorSerializer = Class.new(ActiveModel::Serializer) do
has_many :posts, embed: :ids
end
BlogSerializer = Class.new(ActiveModel::Serializer) do
attributes :id, :name
belongs_to :writer
has_many :articles
end