diff options
author | Jon Leighton <j@jonathanleighton.com> | 2012-02-01 15:15:29 -0800 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2012-02-01 15:15:29 -0800 |
commit | 66fc1d6ac8f0f7b797ae18fdcb15cd618e4251f1 (patch) | |
tree | cc114d72e95fd41357677492347fe55139122739 /activerecord/lib/active_record | |
parent | 56ba2103c89c8ee12ecc8995f759c459796fa328 (diff) | |
parent | ee2ae378cb08c4a671c08093ceab77efbd3a001d (diff) | |
download | rails-66fc1d6ac8f0f7b797ae18fdcb15cd618e4251f1.tar.gz rails-66fc1d6ac8f0f7b797ae18fdcb15cd618e4251f1.tar.bz2 rails-66fc1d6ac8f0f7b797ae18fdcb15cd618e4251f1.zip |
Merge pull request #4543 from jdelStrother/find_or_init
Don't instantiate two objects in collection proxy / find_or_instantiate_by
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_proxy.rb | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index ba01df00e3..5eda0387c4 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) |