diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-22 03:39:36 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-22 03:39:36 +0000 |
commit | 4afd6c9f0a0e97429191af3e3b348ffa4416c640 (patch) | |
tree | af0288db836a551e1d1d06b4b3b5d22f6e6b48bf /activerecord/lib | |
parent | 8ba22a690c65009d0f64e32cd316bc1ca45492c7 (diff) | |
download | rails-4afd6c9f0a0e97429191af3e3b348ffa4416c640.tar.gz rails-4afd6c9f0a0e97429191af3e3b348ffa4416c640.tar.bz2 rails-4afd6c9f0a0e97429191af3e3b348ffa4416c640.zip |
belongs_to assignment creates a new proxy rather than modifying its target in-place. Closes #8412.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6804 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index b13c34d59c..c72024d5f3 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -985,7 +985,7 @@ module ActiveRecord define_method("#{reflection.name}=") do |new_value| association = instance_variable_get("@#{reflection.name}") - if association.nil? + if association.nil? || association.target != new_value association = association_proxy_class.new(self, reflection) end @@ -995,10 +995,7 @@ module ActiveRecord instance_variable_set("@#{reflection.name}", association) else instance_variable_set("@#{reflection.name}", nil) - return nil end - - association end define_method("set_#{reflection.name}_target") do |target| |