We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2d7e38b commit 9e8b6d4Copy full SHA for 9e8b6d4
1 file changed
README.md
@@ -179,6 +179,14 @@ end
179
class PeopleController < ApplicationController
180
181
end
182
+
183
+# Assuming you don't permit user_id (so the client won't assign a wrong user to own the object)
184
+# you can ensure the current user is assigned the record by using the controller's context hash.
185
+class PeopleResource < JSONAPI::Resource
186
+ before_save do
187
+ @model.user_id = context[:current_user].id if @model.new_record?
188
+ end
189
+end
190
```
191
192
You can put things that affect serialization and resource configuration into the context.
0 commit comments