Skip to content

Commit a824376

Browse files
committed
Merge pull request #807 from alexstophel/update-readme
Add Overriding attribute methods section to README.
2 parents 5680436 + 13243f2 commit a824376

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,22 @@ class PostSerializer < ActiveModel::Serializer
163163
end
164164
```
165165

166+
### Overriding attribute methods
167+
168+
If you want to override any attribute, you can use:
169+
170+
```ruby
171+
class PostSerializer < ActiveModel::Serializer
172+
attributes :id, :body
173+
174+
has_many :comments
175+
176+
def body
177+
object.body.downcase
178+
end
179+
end
180+
```
181+
166182
### Built in Adapters
167183

168184
#### JSONAPI

0 commit comments

Comments
 (0)