Skip to content

Commit fb586f2

Browse files
committed
Default Filters
1 parent af72e46 commit fb586f2

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,25 @@ class ContactResource < JSONAPI::Resource
280280
end
281281
```
282282

283+
##### Default Filters
284+
285+
A default filter may be defined for a resource using the `default` option on the `filter` method. This default is used
286+
unless the request overrides this value.
287+
288+
For example:
289+
290+
```ruby
291+
class CommentResource < JSONAPI::Resource
292+
attributes :body, :status
293+
has_one :post
294+
has_one :author
295+
296+
filter :status, default: 'published,pending'
297+
end
298+
```
299+
300+
The default value is used as if it came from the request.
301+
283302
##### Finders
284303

285304
Basic finding by filters is supported by resources. This is implemented in the `find` and `find_by_key` finder methods.

0 commit comments

Comments
 (0)