Rails 中的复数视图问题
我有一个关于复数函数的问题。在我看来,我有以下代码行。它传递具有一定票数的项目,以确定“Vote”一词是否应该采用复数形式。
<%= pluralize(item.votes, 'Vote') %>
我的问题是我的观点传递了“投票”一词,后跟一定数量的投票(item.votes)。我只想让它传递“投票”这个词。非常感谢您的想法。
I have a question about the pluralize function. In my view, I have the following line of code. It passes in an item with a certain number of votes to determine if it the word "Vote" should be pluralized.
<%= pluralize(item.votes, 'Vote') %>
My issue is that my view passes out the word "Votes" followed by the certain number of votes (item.votes). I only want it to pass out the word "Votes". Ideas are much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你可以做的更简单:
You can do simpler:
您可以这样做:
希望有帮助!
You can do:
Hope that helps!
您可以在助手中创建自己的方法
并在您的视图中使用它:
You can create your own method in a helper
and use it in your view: