We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3b1d574 commit e641600Copy full SHA for e641600
1 file changed
README.md
@@ -1495,6 +1495,15 @@ post = Post.find(1)
1495
JSONAPI::ResourceSerializer.new(PostResource).serialize_to_hash(PostResource.new(post, nil))
1496
```
1497
1498
+Note: If your resource needs to access to state from a context hash, make sure to pass the context hash as the second argument of
1499
+the resource class new method. For example:
1500
+
1501
+```ruby
1502
+post = Post.find(1)
1503
+context = { current_user: current_user }
1504
+JSONAPI::ResourceSerializer.new(PostResource).serialize_to_hash(PostResource.new(post, context))
1505
+```
1506
1507
This returns results like this:
1508
1509
```json
0 commit comments