diff options
author | Matt Jones <al2o3cr@gmail.com> | 2008-11-15 01:59:12 -0500 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-11-15 18:20:39 +0100 |
commit | d3fd9971093101712e4cc97ccc534631888b673d (patch) | |
tree | 5a26a28aeef593529ee7acf952da57ef7f0fe3c7 /activerecord/lib/active_record | |
parent | 31be959de746da0b704684e858d1ca69dbf6bf7f (diff) | |
download | rails-d3fd9971093101712e4cc97ccc534631888b673d.tar.gz rails-d3fd9971093101712e4cc97ccc534631888b673d.tar.bz2 rails-d3fd9971093101712e4cc97ccc534631888b673d.zip |
fix assignment to has_one :through associations.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/has_one_through_association.rb | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/has_one_through_association.rb b/activerecord/lib/active_record/associations/has_one_through_association.rb index b78bd5d931..8073ebaf9f 100644 --- a/activerecord/lib/active_record/associations/has_one_through_association.rb +++ b/activerecord/lib/active_record/associations/has_one_through_association.rb @@ -8,11 +8,10 @@ module ActiveRecord current_object = @owner.send(@reflection.through_reflection.name) if current_object - klass.destroy(current_object) - @owner.clear_association_cache + current_object.update_attributes(construct_join_attributes(new_value)) + else + @owner.send(@reflection.through_reflection.name, klass.send(:create, construct_join_attributes(new_value))) end - - @owner.send(@reflection.through_reflection.name, klass.send(:create, construct_join_attributes(new_value))) end private |