From 42dab646eb10e8c7249ad875465679eaf9acc856 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Wed, 1 Feb 2012 15:15:29 -0800 Subject: Merge pull request #4543 from jdelStrother/find_or_init Don't instantiate two objects in collection proxy / find_or_instantiate_by --- activerecord/lib/active_record/associations/collection_proxy.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/associations/collection_proxy.rb') diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index eb320bc774..416a5823c6 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -82,9 +82,8 @@ module ActiveRecord proxy_association.send :add_to_target, r yield(r) if block_given? end - end - if target.respond_to?(method) || (!proxy_association.klass.respond_to?(method) && Class.respond_to?(method)) + elsif target.respond_to?(method) || (!proxy_association.klass.respond_to?(method) && Class.respond_to?(method)) if load_target if target.respond_to?(method) target.send(method, *args, &block) -- cgit v1.2.3