diff options
author | Will Bryant <will.bryant@gmail.com> | 2008-09-27 15:28:21 +1200 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-10-10 16:58:39 +0200 |
commit | 4c05055487e149bfa4152c1b42f3519671ca22ac (patch) | |
tree | e48d836fa25a2c06544b792f4d72c0f7051be9ee /activerecord/lib/active_record/associations.rb | |
parent | 28393e6e9c9368036e65e77175ea4f65a862259c (diff) | |
download | rails-4c05055487e149bfa4152c1b42f3519671ca22ac.tar.gz rails-4c05055487e149bfa4152c1b42f3519671ca22ac.tar.bz2 rails-4c05055487e149bfa4152c1b42f3519671ca22ac.zip |
explicitly including child associations that are also included in the parent association definition should not result in double records in the collection/double loads (#1110)
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1110 state:committed]
Diffstat (limited to 'activerecord/lib/active_record/associations.rb')
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index d1a0b2f96a..7c0d0cb689 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1248,6 +1248,11 @@ module ActiveRecord association.target.nil? ? nil : association end + define_method("loaded_#{reflection.name}?") do + association = instance_variable_get(ivar) if instance_variable_defined?(ivar) + association && association.loaded? + end + define_method("#{reflection.name}=") do |new_value| association = instance_variable_get(ivar) if instance_variable_defined?(ivar) |