【发布时间】:2014-11-19 19:10:31
【问题描述】:
我正在用意大利语构建一个 Rails 应用程序,但我遇到了复数形式的问题。
我有一个名为“Distintivo”的模型,我可以正确地将其复数为“Distintivo”,还有一个名为“Socio”的模型,我可以正确地将其复数为“Soci”,但我需要另一个模型来制作连接表。我想将此模型称为“DistintivoSocio”并将其复数为“DistintivoSoci”,但是当我生成脚手架时,Rails 选择 distintivo_soci,忽略我的 inflections.rb,如下所示:
inflect.irregular 'distintivo', 'distintivi'
inflect.irregular 'socio', 'soci'
inflect.irregular 'distintivo_socio', 'distintivi_soci'
我也试过
inflect.irregular 'distintivosocio', 'distintivisoci'
但我没有运气。有什么想法吗?
如果意大利语语法很奇怪,请见谅。
【问题讨论】:
-
我的假设是脚手架行为是选择
first.singular_second.plural而不是(first_second).plural,因为连接模型是单个第一个实例和第二个实例之间的多个链接。 -
你为什么要上课
DistintivoSocio?对于has_and_belongs_to_many关联,Rails 通常不需要这样的模型。 -
我相信this 的帖子很好地解释了为什么我们选择使用模型而不是 has_and_belongs_to_many 关联。
标签: ruby-on-rails ruby ruby-on-rails-4