method
second_to_last
v7.0.0 -
Show latest stable
- Class:
ActiveRecord::FinderMethods
second_to_last()public
Find the second-to-last record. If no order is defined it will order by primary key.
Person.second_to_last # returns the second-to-last object fetched by SELECT * FROM people Person.offset(3).second_to_last # returns the second-to-last object from OFFSET 3 Person.where(["user_name = :u", { u: user_name }]).second_to_last