From 13243f2e707d903abccbeab82b8c7f32ebb1a669 Mon Sep 17 00:00:00 2001 From: Alex Stophel Date: Sat, 7 Feb 2015 00:09:50 -0500 Subject: [PATCH] Add Overriding attribute methods section to README. --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index e6a560fd..2f1cc4ec 100644 --- a/README.md +++ b/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