Greg Hauptmann wrote: > Hi, > > What's a good approach for referencing lookup/reference data (static) > that one has loaded in a reference table. Say for example "tax codes", > which pretty much have just the database ID and then a description > field. Some options that come to mind: > > 1 - By ID - however this makes an assumption that the data always loads > into a database and gets the same IDs (i.e. when you're loading your > static reference data)? > > 2 - Search by description to identify the record - but obviously if one > changes the description this isn't very good. > > 3 - Perhaps create a specific identify/key as a new column that you use, > but is not the database Rails ID? How's this sound?
I'd recommend the enumerations_mixin plugin that both caches the table and allows lookup and by id and (unique) name. e.g. self.tax_code = :exempt if tax_code === :exempt ... http://svn.protocool.com/public/plugins/enumerations_mixin/ -- Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

