Forum: Ruby on Rails RE: Inserting the parent Id to the child table

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Hogan, Brian P. (Guest)
on 2006-01-19 21:37
(Received via mailing list)
I'll probably get flamed for saying this but
     @addresses =[:addresses])

Is what I usually do if I'm associating something to another thing that
already exists.

If I have a student already in the DB, I'm just going to embed the id on
the form or in session and directly add the value just like you did...
In my opinion, (and that's all it is), why should I create an instance
of a student object (1 extra sql statement to populate the object) when
I already have the ID of the record in my session or in my form? I'll
save some processing time and just associate it by hand.

If I'm creating the student and address at the same time, then other
methods are more appropriate.
This topic is locked and can not be replied to.