Skip to content

Commit

Permalink
Merge pull request #327 from ansonhoyt/master
Browse files Browse the repository at this point in the history
Update docs with example of attribute named "object"
  • Loading branch information
steveklabnik committed Jun 6, 2013
2 parents edb673e + 173f3f2 commit 614edef
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,18 @@ end
Within a serializer's methods, you can access the object being
serialized as `object`.

Since this shadows any attribute named `object`, you can include them through `object.object`. For example:

```ruby
class VersionSerializer < ActiveModel::Serializer
attribute :version_object, key: :object

def version_object
object.object
end
end
```

You can also access the `current_user` method, which provides an
authorization context to your serializer. By default, the context
is the current user of your application, but this
Expand Down

0 comments on commit 614edef

Please sign in to comment.