mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Add Overriding attribute methods section to README.
This commit is contained in:
parent
5680436f9e
commit
13243f2e70
16
README.md
16
README.md
@ -163,6 +163,22 @@ class PostSerializer < ActiveModel::Serializer
|
||||
end
|
||||
```
|
||||
|
||||
### Overriding attribute methods
|
||||
|
||||
If you want to override any attribute, you can use:
|
||||
|
||||
```ruby
|
||||
class PostSerializer < ActiveModel::Serializer
|
||||
attributes :id, :body
|
||||
|
||||
has_many :comments
|
||||
|
||||
def body
|
||||
object.body.downcase
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
### Built in Adapters
|
||||
|
||||
#### JSONAPI
|
||||
|
||||
Loading…
Reference in New Issue
Block a user