diff options
author | Brian Christian <brchristian@gmail.com> | 2016-02-10 10:10:38 -0800 |
---|---|---|
committer | Brian Christian <brchristian@gmail.com> | 2016-02-10 10:10:38 -0800 |
commit | e8aeda2ab39b5d416a72edfa74e0fb17721eb6f9 (patch) | |
tree | ea2b76a40f9d9ce3046a9fae3f177b9e4c0b1706 /activerecord/lib/active_record/relation | |
parent | c74045cf0771ab51dfeca94b30c447cab6193e60 (diff) | |
download | rails-e8aeda2ab39b5d416a72edfa74e0fb17721eb6f9.tar.gz rails-e8aeda2ab39b5d416a72edfa74e0fb17721eb6f9.tar.bz2 rails-e8aeda2ab39b5d416a72edfa74e0fb17721eb6f9.zip |
rename to 'second_to_last' and 'third_to_last'
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 90e05dc340..90a6a466fd 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -245,32 +245,32 @@ module ActiveRecord # Find the third-to-last record. # If no order is defined it will order by primary key. # - # Person.antepenultimate # returns the third-to-last object fetched by SELECT * FROM people - # Person.offset(3).antepenultimate # returns the third-to-last object from OFFSET 3 - # Person.where(["user_name = :u", { u: user_name }]).antepenultimate - def antepenultimate + # 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 = :u", { u: user_name }]).third_to_last + def third_to_last find_nth -3 end - # Same as #antepenultimate but raises ActiveRecord::RecordNotFound if no record + # Same as #third_to_last but raises ActiveRecord::RecordNotFound if no record # is found. - def antepenultimate! + def third_to_last! find_nth! -3 end # Find the second-to-last record. # If no order is defined it will order by primary key. # - # Person.penultimate # returns the second-to-last object fetched by SELECT * FROM people - # Person.offset(3).penultimate # returns the second-to-last object from OFFSET 3 - # Person.where(["user_name = :u", { u: user_name }]).penultimate - def penultimate + # 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 + def second_to_last find_nth -2 end - # Same as #penultimate but raises ActiveRecord::RecordNotFound if no record + # Same as #second_to_last but raises ActiveRecord::RecordNotFound if no record # is found. - def penultimate! + def second_to_last! find_nth! -2 end |