From c6e01f5b60c4864f0e92149d1e81077519f503d5 Mon Sep 17 00:00:00 2001 From: Florian Weber Date: Wed, 21 Dec 2005 15:50:31 +0000 Subject: 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 --- activerecord/lib/active_record/associations.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'activerecord/lib') 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 -- cgit v1.2.3