It is interesting to think about traditional db “lookup” tables in
rails. Consider the notion of a “stage.” A stage can be “active”,
“suspended”, “completed”, “terminated”, etc. In rails thinking I would
have some object models which happen to be “stageable” (polymorphic
associations). Example: an employee could be stageable (employee could
have many stages- each stage has a stage type). Obviously, the
“stage_type” model is the traditional lookup table.
Maybe I lack proper understanding but I tend to fear the “find(:all…)”
method because I am thinking in terms of thousands of rows. I want to
return a list of objects which have some “stage” in the lookup table
(with some other conditions). But why do I have to load the whole
I mean it seams like I am forced to load that whole collection and then
do operations on the collection to group them by stage type (the lookup
table). Then I would have to extract the grouped subset.
Is there not a better way? I am trying to think about it without
resorting to a new join model (since I don’t know how I would
parameterize the join model for the different values in the lookup
Can anyone help straighten my wayward thinking?