Skip to content

Commit bc6ad3c

Browse files
committed
Fix order of applies
1 parent 216cb70 commit bc6ad3c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/jsonapi/active_record_accessor.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ def apply_pagination(records, paginator, order_options)
210210
end
211211

212212
def apply_sort(records, order_options, context = {})
213+
if defined?(_resource_klass.apply_sort)
214+
custom_sort = _resource_klass.apply_sort(records, order_options, context)
215+
records = custom_sort unless custom_sort.nil?
216+
end
217+
213218
if order_options.any?
214219
order_options.each_pair do |field, direction|
215220
if field.to_s.include?(".")
@@ -227,9 +232,7 @@ def apply_sort(records, order_options, context = {})
227232
end
228233
end
229234

230-
return records unless defined?(_resource_klass.apply_sort)
231-
custom_sort = _resource_klass.apply_sort(records, order_options, context)
232-
custom_sort.nil? ? records : custom_sort
235+
records
233236
end
234237

235238
def _lookup_association_chain(model_names)

0 commit comments

Comments
 (0)