开发者

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
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜