aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2006-08-08 16:59:06 +0000
committerRick Olson <technoweenie@gmail.com>2006-08-08 16:59:06 +0000
commit94a1309194fa5962e33d395ede14e94b237c54f5 (patch)
tree33c1e6edbe2297e9f19206c18480db5b76bafd84 /activerecord/lib/active_record/associations
parent2ce49e7dd56515491238ccb7961987ea82055105 (diff)
downloadrails-94a1309194fa5962e33d395ede14e94b237c54f5.tar.gz
rails-94a1309194fa5962e33d395ede14e94b237c54f5.tar.bz2
rails-94a1309194fa5962e33d395ede14e94b237c54f5.zip
Cache nil results for has_one associations so multiple calls don't call the database. Closes #5757. [Michael A. Schoen]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4721 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/association_proxy.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb
index 46804a3b93..a94daccd34 100644
--- a/activerecord/lib/active_record/associations/association_proxy.rb
+++ b/activerecord/lib/active_record/associations/association_proxy.rb
@@ -126,13 +126,13 @@ module ActiveRecord
def load_target
if !@owner.new_record? || foreign_key_present
begin
- @target = find_target if !loaded?
+ @target = find_target unless loaded?
rescue ActiveRecord::RecordNotFound
reset
end
end
- loaded if target
+ loaded
target
end