Rails:搬运脚手架,例如"Sheep".具有相同的复数和单数形式 [英] Rails: Handling a scaffolding, such as "Sheep," that has the same plural and singular form

查看:136
本文介绍了Rails:搬运脚手架,例如"Sheep".具有相同的复数和单数形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个称为CommunicationMeans的模型(或者,MeansOfCommunication).但是,这是该术语的单数形式和复数形式.我跑了:

I'm wanting to create a model called CommunicationMeans (or, alternatively, MeansOfCommunication). However, this is both the singular and plural form of this term. I ran this:

$ rails g scaffold CommunicationMeans

它生成了一个名为CommunicationMean的模型和一个名为CommunicationMeansController的控制器.我需要将该模型也命名为CommunicationMeans.我隐约记得某些文档中使用Sheep模型的示例,但是处理这种情况的正确"方法是什么?谢谢.

It generated a model named CommunicationMean and a controller named CommunicationMeansController. I need the model to also be named CommunicationMeans. I vaguely remember an example in some documentation using a Sheep model, but what is the "correct" way to handle this situation? Thanks.

推荐答案

在config/initializers/inflections.rb中,您可以将'means'添加为不可数.

In config/initializers/inflections.rb, you can add 'means' as uncountable.

好吧,在骆驼的情况下,必须添加整个化合物,但是它起作用了:

Ok, had to add the whole compound, in camel case, but it worked:

ActiveSupport::Inflector.inflections do |inflect|
   inflect.uncountable 'CommunicationMeans'
end

这篇关于Rails:搬运脚手架,例如"Sheep".具有相同的复数和单数形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆