File tree 2 files changed +6
-1
lines changed
lib/elasticsearch/model/adapters
2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,10 @@ def order(*args)
56
56
# Redefine the `to_a` method to the original one
57
57
#
58
58
sql_records . instance_exec do
59
- define_singleton_method ( :to_a ) do
59
+ ar_records_method_name = :to_a
60
+ ar_records_method_name = :records if defined? ( ::ActiveRecord ) && ::ActiveRecord ::VERSION ::MAJOR >= 5
61
+
62
+ define_singleton_method ( ar_records_method_name ) do
60
63
if defined? ( ::ActiveRecord ) && ::ActiveRecord ::VERSION ::MAJOR >= 4
61
64
self . load
62
65
else
Original file line number Diff line number Diff line change @@ -223,8 +223,10 @@ def as_indexed_json(options = {})
223
223
224
224
if defined? ( ::ActiveRecord ) && ::ActiveRecord ::VERSION ::MAJOR >= 4
225
225
assert_equal 'Testing Coding' , response . records . order ( title : :desc ) . first . title
226
+ assert_equal 'Testing Coding' , response . records . order ( title : :desc ) [ 0 ] . title
226
227
else
227
228
assert_equal 'Testing Coding' , response . records . order ( 'title DESC' ) . first . title
229
+ assert_equal 'Testing Coding' , response . records . order ( 'title DESC' ) [ 0 ] . title
228
230
end
229
231
end
230
232
You can’t perform that action at this time.
0 commit comments