You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-20Lines changed: 23 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,7 @@ backed by ActiveRecord models or by custom objects.
21
21
*[Usage] (#usage)
22
22
*[Resources] (#resources)
23
23
*[JSONAPI::Resource] (#jsonapiresource)
24
+
*[Context] (#context)
24
25
*[Attributes] (#attributes)
25
26
*[Primary Key] (#primary-key)
26
27
*[Model Name] (#model-name)
@@ -160,6 +161,28 @@ In the above example vehicles are immutable. A call to `/vehicles` or `/vehicles
160
161
of either `car` or `boat`. But calls to PUT or POST a `car` must be made to `/cars`. The rails models backing the above
161
162
code use Single Table Inheritance.
162
163
164
+
#### Context
165
+
166
+
Sometimes you will want to access things such as the current logged in user (and other state only available within your controllers) from within your resource classes. To make this state available to a resource class you need to put it into the context hash - this can be done via a `context` method on one of your controllers or across all controllers using ApplicationController.
0 commit comments