DataMapper association: How do I specify table name that contains the associated rows?
I a开发者_如何学Pythonm working with a database that is already in place and used by other applications.
The people who designed the database did not use pluralized table names, so DataMapper chooses the wrong table name when following associations.
For instance:
class Foo
has n :components # => the table name here should be COMPONENT, but datamapper uses COMPONENTS
end
How do I change this behavior?
Change the name on the model itself.
class Component
# ...
storage_names[:default] = 'component'
end
精彩评论