search for: attributes_of_car2

Displaying 1 result from an estimated 1 matches for "attributes_of_car2".

Did you mean: attributes_of_car
2007 May 14
0
building and saving has_many and has_one relations
...ins. Take the same scenario, but now a student can own one or more cars: class Student has_many(:cars) end class Car belongs_to(:student) validates_presence_of(:student_id) end When I do student = Student.new(attributes_of_student) student.cars.build(attributes_of_car1) student.cars.build(attributes_of_car2) Until now, everything is fine, except that the cars are part of the cars collection of student, which doesn''t happen according to the doc [2]. The real problem comes when I do student.save! It won''t save when there are invalid cars, and the cars are always invalid, because stu...