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

@@ -146,6 +146,22 @@ call:
render json: @post, root: "articles"
```
### Overriding association methods
If you want to override any association, you can use:
```ruby
class PostSerializer < ActiveModel::Serializer
attributes :id, :body
has_many :comments
def comments
object.comments.active
end
end
```
### Built in Adapters
#### JSONAPI