有没有办法在模型而不是视图中使用复数()? [英] Is there a way to use pluralize() inside a model rather than a view?
本文介绍了有没有办法在模型而不是视图中使用复数()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
似乎 pluralize
只能在视图中使用——有什么方法可以让我的模型也使用 pluralize
?
It seems pluralize
only works within a view -- is there some way that my models can use pluralize
too?
推荐答案
与其扩展事物,我只是这样:
Rather than extend things, I just it like this:
ActionController::Base.helpers.pluralize(count, 'mystring')
希望这对其他人有帮助!
Hope this helps someone else!
这篇关于有没有办法在模型而不是视图中使用复数()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文