README.markdown in active_model_serializers-0.5.1 vs README.markdown in active_model_serializers-0.5.2
- old
+ new
@@ -124,16 +124,16 @@
attributes :id, :title, :body
has_many :comments
# only let the user see comments he created.
def comments
- post.comments.where(:created_by => @scope)
+ post.comments.where(:created_by => options[:scope])
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
`render :json`
As with attributes, you can also change the JSON key that the serializer should
use for a particular association.
@@ -217,14 +217,14 @@
{
"post": {
"id": 1,
"title": "New post",
"body": "A body!",
- "comments": [ 1 ]
+ "comments": [ 1, 2 ]
},
"comments": [
{ "id": 1, "body": "what a dumb post", "tags": [ 1, 2 ] },
- { "id": 1, "body": "i liked it", "tags": [ 1, 3 ] },
+ { "id": 2, "body": "i liked it", "tags": [ 1, 3 ] },
],
"tags": [
{ "id": 1, "name": "short" },
{ "id": 2, "name": "whiny" },
{ "id": 3, "name": "happy" }