【问题标题】:Pluralization of multi-word scaffold name in Rails 4Rails 4中多字脚手架名称的复数
【发布时间】: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


【解决方案1】:

当一个变形包含在另一个变形中时,顺序很重要。试试:

inflect.irregular 'distintivo_socio', 'distintivi_soci'
inflect.irregular 'distintivo',       'distintivi'
inflect.irregular 'socio',            'soci'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-21
    • 1970-01-01
    • 1970-01-01
    • 2014-06-06
    • 1970-01-01
    • 1970-01-01
    • 2011-12-20
    • 2011-03-21
    相关资源
    最近更新 更多