mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
@scope seems to be deprecated - updated the readme to reflect options[:scope]
This commit is contained in:
parent
5beecd5947
commit
f448a1651a
@ -126,12 +126,12 @@ class PostSerializer < ActiveModel::Serializer
|
|||||||
|
|
||||||
# only let the user see comments he created.
|
# only let the user see comments he created.
|
||||||
def comments
|
def comments
|
||||||
post.comments.where(:created_by => @scope)
|
post.comments.where(:created_by => options[:scope])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
In a serializer, `@scope` is the current authorization scope (usually
|
In a serializer, `options[:scope]` is the current authorization scope (usually
|
||||||
`current_user`), which the controller gives to the serializer when you call
|
`current_user`), which the controller gives to the serializer when you call
|
||||||
`render :json`
|
`render :json`
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user