Support overriding association methods

You can override associations to define custom scope on them.
This commit is contained in:
Alexandre de Oliveira
2015-01-29 16:48:41 -02:00
parent 652493848a
commit e47231cdc8
15 changed files with 106 additions and 13 deletions

View File

@@ -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