1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #23303 from Empact/find-nth-deprecation

Consistently warn that passing an offset to `find_nth` is deprecated
This commit is contained in:
Rafael França 2016-01-28 06:40:50 -05:00
commit ac0446870f

View file

@ -489,9 +489,6 @@ module ActiveRecord
end end
def find_nth(index, offset = nil) def find_nth(index, offset = nil)
if loaded?
@records[index]
else
# TODO: once the offset argument is removed we rely on offset_index # TODO: once the offset argument is removed we rely on offset_index
# within find_nth_with_limit, rather than pass it in via # within find_nth_with_limit, rather than pass it in via
# find_nth_with_limit_and_offset # find_nth_with_limit_and_offset
@ -500,9 +497,11 @@ module ActiveRecord
Passing an offset argument to find_nth is deprecated, Passing an offset argument to find_nth is deprecated,
please use Relation#offset instead. please use Relation#offset instead.
MSG MSG
else
offset = offset_index
end end
if loaded?
@records[index]
else
offset ||= offset_index
@offsets[offset + index] ||= find_nth_with_limit_and_offset(index, 1, offset: offset).first @offsets[offset + index] ||= find_nth_with_limit_and_offset(index, 1, offset: offset).first
end end
end end