On 26/11/2010, at 3:14 PM, Tim McEwan wrote:
> I have a model that has_one "ANZIC code".  ANZIC codes are classifiers set by 
> the gov that are 4 or fewer levels deep: division, sub-division, class & 
> group.
> Most of the time, the objects we're tracking won't have an advertised code, 
> so the data entry person will need to drill down into the classifications to 
> hone in on the most appropriate code.  I'm thinking 4 sequential select lists 
> for UI.  (Let me know if you've a better idea. :-)

I had a very similar problem, in working out demographics, broken down by 
country, state, suburb and then store.

Country, State and Suburb were all pretty fixed (post codes and state boundary 
lines don't change that often)  store however was a totally arbitrary thing, 
you could have 1 store per suburb or 10... each demographic had to store 
values, and these values had to be aggregated up the tree.

The solution was a nested set, called a demographic, and then this related to a 
location through polymorphism.  Whether the demographic was a top level 
(country) mid level, or bottom level item just depended on whom its parent is.  
Its behaviour was then controlled by the associated location object.

It might seem like a bit or work, but really, this is what nested sets are made 
for.

Hope that helps


Mikel Lindsaar
http://rubyx.com/
http://lindsaar.net/




-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en.

Reply via email to