mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Support overriding association methods
You can override associations to define custom scope on them.
This commit is contained in:
5
test/fixtures/poro.rb
vendored
5
test/fixtures/poro.rb
vendored
@@ -54,8 +54,13 @@ PostSerializer = Class.new(ActiveModel::Serializer) do
|
||||
attributes :title, :body, :id
|
||||
|
||||
has_many :comments
|
||||
belongs_to :blog
|
||||
belongs_to :author
|
||||
url :comments
|
||||
|
||||
def blog
|
||||
Blog.new(id: 999, name: "Custom blog")
|
||||
end
|
||||
end
|
||||
|
||||
SpammyPostSerializer = Class.new(ActiveModel::Serializer) do
|
||||
|
||||
Reference in New Issue
Block a user