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

Jos*_*ehl 0 ruby datamapper associations

我正在使用已经存在并由其他应用程序使用的数据库.

设计数据库的人没有使用多个表名,因此DataMapper在跟随关联时选择了错误的表名.

例如:

class Foo
  has n :components # => the table name here should be COMPONENT, but datamapper uses COMPONENTS
end 
Run Code Online (Sandbox Code Playgroud)

我该如何改变这种行为?

Mat*_*chu 9

更改模型本身的名称.

class Component
  # ...
  storage_names[:default] = 'component'
end
Run Code Online (Sandbox Code Playgroud)