diff options
author | Florian Weber <csshsh@gmail.com> | 2005-12-21 15:50:31 +0000 |
---|---|---|
committer | Florian Weber <csshsh@gmail.com> | 2005-12-21 15:50:31 +0000 |
commit | c6e01f5b60c4864f0e92149d1e81077519f503d5 (patch) | |
tree | 40cc1aee95728263ea5d80c940759822b8d61aa2 /activerecord/lib/active_record/associations.rb | |
parent | 43f6643b8b3a6892105ba9db23bdafd4c8d49ac3 (diff) | |
download | rails-c6e01f5b60c4864f0e92149d1e81077519f503d5.tar.gz rails-c6e01f5b60c4864f0e92149d1e81077519f503d5.tar.bz2 rails-c6e01f5b60c4864f0e92149d1e81077519f503d5.zip |
Fixed that saving a model with multiple habtm associations, would only save the first habtm association.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3331 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/associations.rb')
-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 562a2dc6b7..ea442021c5 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -727,7 +727,6 @@ module ActiveRecord def add_multiple_associated_save_callbacks(association_name) method_name = "validate_associated_records_for_#{association_name}".to_sym define_method(method_name) do - @new_record_before_save = new_record? association = instance_variable_get("@#{association_name}") if association.respond_to?(:loaded?) if new_record? @@ -741,6 +740,7 @@ module ActiveRecord end validate method_name + before_save("@new_record_before_save = new_record?; true") after_callback = <<-end_eval association = instance_variable_get("@#{association_name}") @@ -754,9 +754,6 @@ module ActiveRecord records_to_save.each { |record| association.send(:insert_record, record) } association.send(:construct_sql) # reconstruct the SQL queries now that we know the owner's id end - - @new_record_before_save = false - true end_eval # Doesn't use after_save as that would save associations added in after_create/after_update twice |