Forum: Ruby on Rails ActiveRecords: save & relationships

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Andre P. (Guest)
on 2005-12-22 22:27
Dear all,

How many steps does 'save method' save in has_many/belongs_to
relationships ?

Just to exemplify,  let's suppose:

School  has_many Classes
Classes has_many Students

School.name   = 'school'
Class.name    = 'class'
Student1.name = 'student1'
Student2.name = 'student2'

Class.students << Student1
Class.students << Student2
School.Classes << Class

School.save

Should i have everything saved in the database ?
In a real situation, i'm having students with null class_id's.
Is that ok ?

Many thanks,
Andre
This topic is locked and can not be replied to.