Skip to content

Commit 51570ad

Browse files
committed
Refactor
1 parent bc6ad3c commit 51570ad

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/jsonapi/active_record_accessor.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,13 @@ def apply_pagination(records, paginator, order_options)
212212
def apply_sort(records, order_options, context = {})
213213
if defined?(_resource_klass.apply_sort)
214214
custom_sort = _resource_klass.apply_sort(records, order_options, context)
215-
records = custom_sort unless custom_sort.nil?
215+
custom_sort.nil? ? default_sort(records, order_options) : custom_sort
216+
else
217+
default_sort(records, order_options)
216218
end
219+
end
217220

221+
def default_sort(records, order_options)
218222
if order_options.any?
219223
order_options.each_pair do |field, direction|
220224
if field.to_s.include?(".")

0 commit comments

Comments
 (0)