aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/collection_proxy.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-07-31 22:03:57 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-08-16 22:46:59 +0900
commit46380674d31af542a07de93a21d6be3a9cddb64b (patch)
tree3d99af16e9694ea73be6bf0bdbd77191f6df0ba8 /activerecord/lib/active_record/associations/collection_proxy.rb
parent82ec6b36065e91fe0ec5a87f9419840618ce2c5d (diff)
downloadrails-46380674d31af542a07de93a21d6be3a9cddb64b.tar.gz
rails-46380674d31af542a07de93a21d6be3a9cddb64b.tar.bz2
rails-46380674d31af542a07de93a21d6be3a9cddb64b.zip
Fix inconsistent the signature of finder methods for collection association
`#second`, `#third`, etc finder methods was added in 03855e790de2224519f55382e3c32118be31eeff. But the signature of these methods is inconsistent with the original finder methods. And also the signature of `#first` and `#last` methods is different from the original. This commit fixes the inconsistency.
Diffstat (limited to 'activerecord/lib/active_record/associations/collection_proxy.rb')
-rw-r--r--activerecord/lib/active_record/associations/collection_proxy.rb36
1 files changed, 18 insertions, 18 deletions
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb
index fb1b31429e..a3aef07746 100644
--- a/activerecord/lib/active_record/associations/collection_proxy.rb
+++ b/activerecord/lib/active_record/associations/collection_proxy.rb
@@ -167,44 +167,44 @@ module ActiveRecord
# another_person_without.pets # => []
# another_person_without.pets.first # => nil
# another_person_without.pets.first(3) # => []
- def first(*args)
- @association.first(*args)
+ def first(limit = nil)
+ @association.first(limit)
end
# Same as #first except returns only the second record.
- def second(*args)
- @association.second(*args)
+ def second
+ @association.second
end
# Same as #first except returns only the third record.
- def third(*args)
- @association.third(*args)
+ def third
+ @association.third
end
# Same as #first except returns only the fourth record.
- def fourth(*args)
- @association.fourth(*args)
+ def fourth
+ @association.fourth
end
# Same as #first except returns only the fifth record.
- def fifth(*args)
- @association.fifth(*args)
+ def fifth
+ @association.fifth
end
# Same as #first except returns only the forty second record.
# Also known as accessing "the reddit".
- def forty_two(*args)
- @association.forty_two(*args)
+ def forty_two
+ @association.forty_two
end
# Same as #first except returns only the third-to-last record.
- def third_to_last(*args)
- @association.third_to_last(*args)
+ def third_to_last
+ @association.third_to_last
end
# Same as #first except returns only the second-to-last record.
- def second_to_last(*args)
- @association.second_to_last(*args)
+ def second_to_last
+ @association.second_to_last
end
# Returns the last record, or the last +n+ records, from the collection.
@@ -233,8 +233,8 @@ module ActiveRecord
# another_person_without.pets # => []
# another_person_without.pets.last # => nil
# another_person_without.pets.last(3) # => []
- def last(*args)
- @association.last(*args)
+ def last(limit = nil)
+ @association.last(limit)
end
# Gives a record (or N records if a parameter is supplied) from the collection