DataMapper关联:如何指定包含关联行的表名?
问题描述:
我正在使用已经存在并由其他应用程序使用的数据库。DataMapper关联:如何指定包含关联行的表名?
设计数据库的人没有使用复数表名,所以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
啊哈!谢谢。我是DataMapper的新手,所以我没有想到要这么做。 :) – 2010-07-16 20:03:55