Changeset 3331
- Timestamp:
- 12/21/05 15:50:31 (3 years ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/associations.rb (modified) (3 diffs)
- trunk/activerecord/test/associations_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r3328 r3331 1 1 *SVN* 2 3 * Fixed that saving a model with multiple habtm associations, would only save the first habtm association. #3244 [yanowitz-rubyonrails@quantumfoam.org, Florian Weber] 2 4 3 5 * Fix change_column to work with PostgreSQL 7.x and 8.x. #3141 [wejn@box.cz, Rick Olson, Scott Barron] trunk/activerecord/lib/active_record/associations.rb
r3326 r3331 728 728 method_name = "validate_associated_records_for_#{association_name}".to_sym 729 729 define_method(method_name) do 730 @new_record_before_save = new_record?731 730 association = instance_variable_get("@#{association_name}") 732 731 if association.respond_to?(:loaded?) … … 742 741 743 742 validate method_name 743 before_save("@new_record_before_save = new_record?; true") 744 744 745 745 after_callback = <<-end_eval … … 755 755 association.send(:construct_sql) # reconstruct the SQL queries now that we know the owner's id 756 756 end 757 758 @new_record_before_save = false759 true760 757 end_eval 761 758 trunk/activerecord/test/associations_test.rb
r3287 r3331 1195 1195 end 1196 1196 1197 def test_habtm_saving_multiple_relationships 1198 new_project = Project.new("name" => "Grimetime") 1199 amount_of_developers = 4 1200 developers = (0..amount_of_developers).collect {|i| Developer.create(:name => "JME #{i}") } 1201 1202 new_project.developer_ids = [developers[0].id, developers[1].id] 1203 new_project.developers_with_callback_ids = [developers[2].id, developers[3].id] 1204 assert new_project.save 1205 1206 new_project.reload 1207 assert_equal amount_of_developers, new_project.developers.size 1208 amount_of_developers.times do |i| 1209 assert_equal developers[i].name, new_project.developers[i].name 1210 end 1211 end 1212 1197 1213 def test_build 1198 1214 devel = Developer.find(1)