aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorFlorian Weber <csshsh@gmail.com>2005-12-21 15:50:31 +0000
committerFlorian Weber <csshsh@gmail.com>2005-12-21 15:50:31 +0000
commitc6e01f5b60c4864f0e92149d1e81077519f503d5 (patch)
tree40cc1aee95728263ea5d80c940759822b8d61aa2 /activerecord/lib
parent43f6643b8b3a6892105ba9db23bdafd4c8d49ac3 (diff)
downloadrails-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')
-rwxr-xr-xactiverecord/lib/active_record/associations.rb5
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