=== modified file 'vendor/rails/activerecord/lib/active_record/autosave_association.rb' --- vendor/rails/activerecord/lib/active_record/autosave_association.rb 2009-04-03 13:23:10 +0000 +++ vendor/rails/activerecord/lib/active_record/autosave_association.rb 2009-06-17 21:32:26 +0000 @@ -313,9 +313,12 @@ if (association = association_instance_get(reflection.name)) && !association.target.nil? if reflection.options[:autosave] && association.marked_for_destruction? association.destroy - elsif new_record? || association.new_record? || association[reflection.primary_key_name] != id || reflection.options[:autosave] - association[reflection.primary_key_name] = id - association.save(false) + else + id_col_val = reflection.options[:primary_key] ? self.send(reflection.options[:primary_key]) : id + if new_record? || association.new_record? || association[reflection.primary_key_name] != id_col_val || reflection.options[:autosave] + association[reflection.primary_key_name] = id_col_val + association.save(false) + end end end end @@ -346,4 +349,4 @@ end end end -end \ No newline at end of file +end