On Sun, 25 Oct 2009 15:20:24 -0700 (PDT) sebastien barre <[email protected]> wrote:
> > I'm working with a legacy database and I've been trying to figure out > how to override storage_name.. Right now I have a class called Staff > that sets it's storage_name to "staffs" when I need to be "staff". > > While digging around the IRC logs and this list, I've come across the > following method, that actually does work: > > SNIP example > > What I am curious about is if I missed some easier way of doing this? > I didn't see anything in the API or the Wiki or the docs.. The above > approach seems pretty clunky.. > There are a few ways to handle this. You could define 'staff' as a collective noun via: Extlib::Inflection.word 'staff' Or you could do: class Staff include DataMapper::Resource storage_names[:default] = 'staff' # or which ever repo it is end Or if it's a lot of tables, you could look into NamingConventions (check the rdoc) Regards Jon --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DataMapper" 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/datamapper?hl=en -~----------~----~----~----~------~----~------~--~---
