diff options
Diffstat (limited to 'activerecord/lib/active_record/associations/association_proxy.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/association_proxy.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb index 59b0c54f2f..ead2c5ede2 100644 --- a/activerecord/lib/active_record/associations/association_proxy.rb +++ b/activerecord/lib/active_record/associations/association_proxy.rb @@ -226,18 +226,19 @@ module ActiveRecord # ActiveRecord::RecordNotFound is rescued within the method, and it is # not reraised. The proxy is \reset and +nil+ is the return value. def load_target - if !loaded? && (!@owner.new_record? || foreign_key_present?) && target_klass - @target = find_target - end - + @target = find_target if find_target? loaded - @target + target rescue ActiveRecord::RecordNotFound reset end private + def find_target? + !loaded? && (!@owner.new_record? || foreign_key_present?) && target_klass + end + def interpolate_sql(sql, record = nil) @owner.send(:interpolate_sql, sql, record) end |