diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-09-12 20:53:05 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-09-12 20:53:05 -0300 |
commit | 33ae757376f6d97f5580bfa6f03ce8da09d7780a (patch) | |
tree | 56c7b9ce9599149f4cd8a0eaaea968e338b8dbca /activerecord/lib/active_record | |
parent | e1154a694d861abbcc1f8f1c8d557d2e349ba9c2 (diff) | |
parent | 8875e28a50b117aa862c8563c49f7e3a6ee7deff (diff) | |
download | rails-33ae757376f6d97f5580bfa6f03ce8da09d7780a.tar.gz rails-33ae757376f6d97f5580bfa6f03ce8da09d7780a.tar.bz2 rails-33ae757376f6d97f5580bfa6f03ce8da09d7780a.zip |
Merge pull request #12137 from lann/fix_association_first_last
Make CollectionAssociation first/last with integer fetch with query
Conflicts:
activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_association.rb | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index 8744a57355..e32c0b0377 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -528,15 +528,13 @@ module ActiveRecord # * target already loaded # * owner is new record # * target contains new or changed record(s) - # * the first arg is an integer (which indicates the number of records to be returned) def fetch_first_or_last_using_find?(args) if args.first.is_a?(Hash) true else !(loaded? || owner.new_record? || - target.any? { |record| record.new_record? || record.changed? } || - args.first.kind_of?(Integer)) + target.any? { |record| record.new_record? || record.changed? }) end end |