From dcee137c7b0998b1533c5a028faf5a736078ade3 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 6 Apr 2006 03:06:36 +0000 Subject: [PATCH] Fix HasManyAssociation#find bugs when :finder_sql is set (closes #4600) [lagroue@free.fr] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4176 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/CHANGELOG | 2 ++ .../lib/active_record/associations/has_many_association.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 2831c377bb..f3139eceba 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed HasManyAssociation#find bugs when :finder_sql is set #4600 [lagroue@free.fr] + * Allow AR::Base#respond_to? to behave when @attributes is nil [zenspider] * Support eager includes when going through a polymorphic has_many association. [Rick] diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index 8d82de0d01..52cad79484 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -59,7 +59,7 @@ def find(*args) if ids.size == 1 id = ids.first record = load_target.detect { |record| id == record.id } - expects_array? ? [record] : record + expects_array ? [ record ] : record else load_target.select { |record| ids.include?(record.id) } end -- GitLab