Prefer explicitly yielding the serializer, per groyoh

This commit is contained in:
Benjamin Fleischer
2016-03-30 13:35:17 -05:00
parent ae6805eacd
commit fa7b3afbfd
4 changed files with 29 additions and 5 deletions

View File

@@ -48,6 +48,18 @@ has_one :blog, key: :site
has_one :maker, virtual_value: { id: 1 }
```
``ruby
has_one :blog do |serializer|
serializer.cached_blog
end
def cached_blog
cache_store.fetch("cached_blog:#{object.updated_at}") do
Blog.find(object.blog_id)
end
end
```
#### ::has_many
e.g.