开发者

DataMapper association: How do I specify table name that contains the associated rows?

开发者 https://www.devze.com 2023-01-07 18:30 出处:网络
I a开发者_如何学Pythonm working with a database that is already in place and used by other applications.

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
0

精彩评论

暂无评论...
验证码 换一张
取 消