Ruby on Rails Friday, July 2, 2010

Thanks, Ar Chron - I'm afraid I don't really understand what you're
suggesting that I do. (sorry..) I already have a cross-reference
table (childx) between the parent and the child that connects them.
In my model, parent has many child, but child can have only one
parent.

The only reason I am defining the child, child1, child2 and child3
inside the parent model is to get a list of child records that belongs
to a parent sorted by different columns in the child table. (I
thought it was an easy and efficient way to get at the record .. :-\
but maybe this is not a good idea?) And my question was if this is
better or worse memory-wise than doing something like this:

# method defined in the Child model
Child.find_by_parent_id(some_parent_id, sort_order)

inside the controller each time I needed a child record pulled sorted
by a different column. (So no child, child1, child2 or child3 defined
in Parent.)

Thanks again - I'll try to read more to understand this. Maybe it'll
lead to what you were trying to tell me in the first place. :-)

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment