We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5efd8e3 commit 2742292Copy full SHA for 2742292
README.md
@@ -72,6 +72,7 @@ You can use `apply_sort` in your controller :
72
class ContactsController < ApplicationController
73
def index
74
@contacts = Contact.apply_sort(params)
75
+ @contacts = Contact.apply_sort # to only apply default sort
76
end
77
78
```
lib/jsonapi/scopes/sorts.rb
@@ -18,7 +18,7 @@ def sortable_fields(*fields)
18
@sortable_fields = fields
19
20
21
- def apply_sort(params, options = { allowed: [], default: {} })
+ def apply_sort(params = {}, options = { allowed: [], default: {} })
22
fields = params.dig(:sort)
23
24
allowed_fields = [options[:allowed]].flatten.presence || @sortable_fields
0 commit comments