Changeset 3332
- Timestamp:
- 12/21/05 16:56:32 (4 years ago)
- Files:
-
- branches/stable/activerecord/CHANGELOG (modified) (1 diff)
- branches/stable/activerecord/lib/active_record/associations.rb (modified) (3 diffs)
- branches/stable/activerecord/test/associations_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/stable/activerecord/CHANGELOG
r3296 r3332 1 * 1 *SVN* 2 3 * Fixed that saving a model with multiple habtm associations would only save the first one. #3244 [yanowitz-rubyonrails@quantumfoam.org, Florian Weber] 4 5 2 6 *1.13.2* (December 13th, 2005) 3 7 branches/stable/activerecord/lib/active_record/associations.rb
r3241 r3332 784 784 method_name = "validate_associated_records_for_#{association_name}".to_sym 785 785 define_method(method_name) do 786 @new_record_before_save = new_record?787 786 association = instance_variable_get("@#{association_name}") 788 787 if association.respond_to?(:loaded?) … … 798 797 799 798 validate method_name 800 799 before_save("@new_record_before_save = new_record?; true") 800 801 801 after_callback = <<-end_eval 802 802 association = instance_variable_get("@#{association_name}") … … 810 810 association.send(:construct_sql) # reconstruct the SQL queries now that we know the owner's id 811 811 end 812 813 @new_record_before_save = false814 true815 812 end_eval 816 813 branches/stable/activerecord/test/associations_test.rb
r3255 r3332 1174 1174 end 1175 1175 1176 def test_habtm_saving_multiple_relationships 1177 new_project = Project.new("name" => "Grimetime") 1178 amount_of_developers = 4 1179 developers = (0..amount_of_developers).collect {|i| Developer.create(:name => "JME #{i}") } 1180 1181 new_project.developer_ids = [developers[0].id, developers[1].id] 1182 new_project.developers_with_callback_ids = [developers[2].id, developers[3].id] 1183 assert new_project.save 1184 1185 new_project.reload 1186 assert_equal amount_of_developers, new_project.developers.size 1187 amount_of_developers.times do |i| 1188 assert_equal developers[i].name, new_project.developers[i].name 1189 end 1190 end 1191 1176 1192 def test_build 1177 1193 devel = Developer.find(1)