File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 188188##### Fetchable Attributes
189189
190190By default all attributes are assumed to be fetchable. The list of fetchable attributes can be filtered by overriding
191- the ` self. fetchable_fields` method.
191+ the ` fetchable_fields ` method.
192192
193193Here's an example that prevents guest users from seeing the ` email ` field:
194194
@@ -198,7 +198,7 @@ class AuthorResource < JSONAPI::Resource
198198 model_name ' Person'
199199 has_many :posts
200200
201- def self . fetchable_fields( context )
201+ def fetchable_fields
202202 if (context[:current_user ].guest)
203203 super - [:email ]
204204 else
Original file line number Diff line number Diff line change @@ -105,8 +105,9 @@ def replace_fields(field_data)
105105 end
106106 end
107107
108+ # Override this on a resource instance to override the fetchable keys
108109 def fetchable_fields
109- self . class . fetchable_fields ( context )
110+ self . class . fields
110111 end
111112
112113 # Override this on a resource to customize how the associated records
@@ -440,11 +441,6 @@ def method_missing(method, *args)
440441 end
441442 # :nocov:
442443
443- # Override in your resource to filter the fetchable keys
444- def fetchable_fields ( _context = nil )
445- fields
446- end
447-
448444 # Override in your resource to filter the updatable keys
449445 def updatable_fields ( _context = nil )
450446 _updatable_relationships | _attributes . keys - [ :id ]
You can’t perform that action at this time.
0 commit comments