mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Add type when association name is different than objects type
This commit is contained in:
8
test/fixtures/poro.rb
vendored
8
test/fixtures/poro.rb
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user