instance method
third_to_last
Ruby on Rails edge
Since v5.0.7.2Signature
third_to_last()
Find the third-to-last record. If no order is defined it will order by primary key.
“‘ Person.third_to_last # returns the third-to-last object fetched by SELECT * FROM people Person.offset(3).third_to_last # returns the third-to-last object from OFFSET 3 Person.where(user_name: user_name).third_to_last “`
Source
# File activerecord/lib/active_record/relation/finder_methods.rb, line 344
def third_to_last
find_nth_from_last 3
end
Defined in activerecord/lib/active_record/relation/finder_methods.rb line 344
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::FinderMethods