繁体   English   中英

DataMapper关联:如何指定包含关联行的表名?

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

我正在使用一个已经存在并已被其他应用程序使用的数据库。

设计数据库的人员没有使用复数的表名,因此DataMapper在遵循关联时会选择错误的表名。

例如:

class Foo
  has n :components # => the table name here should be COMPONENT, but datamapper uses COMPONENTS
end 

如何更改此行为?

更改模型本身的名称。

class Component
  # ...
  storage_names[:default] = 'component'
end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM