Forum: Ruby on Rails RE: Need some advice on DB design

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.
on 2005-12-07 23:26
(Received via mailing list)
"Tom isn't wrong, I just wanted to make sure that nobody misunderstands
and starts doing stuff like messageobject.parent_id ="

Can someone explain to me why

    messageobject.parent_id =

is incorrect? It seems to work, but I'm just curious as to why it's bad.
For example... I may have passed the parent id through the url. Seems
odd that I would have to query the db to populate my parent object just
to make the association to the new child object when I could just add
the id to the child's record.

Of course, if there's a good reason not to do that, I'd really be
interested to know.. I want to make sure I'm doing it right!

Thanks much!
nicholas.stuart (Guest)
on 2005-12-08 01:26
(Received via mailing list)
Its just not really necessary. Most of the time you are dealing with
straight object (as thats the point of the Ruby and OO in general). I
use it mostly when I dont have/cant represent the object in its
natural state (say selecting an object from a drop down list). In
these cases I stick with the ids, but if I actually have the objects I
use the objects. By type more when we dont have to?  :)

This topic is locked and can not be replied to.