I have a question about the pluralization function. In my opinion, I have the following line of code. It passes an item with a certain number of votes to determine if it should be pluralized.
<%= pluralize(item.votes, 'Vote') %>
My problem is that my opinion is conveyed by the word βVoicesβ, followed by a certain number of votes (item.votes). I just want him to convey the word "Voices". Ideas are greatly appreciated.
You can do:
pluralize(items.votes, 'Vote').split(" ", 2)[1]
Hope this helps!
You can make it easier:
"Vote".pluralize(item.votes)
You can create your own method in the helper.
def pluralize_without_count(string, count) count == 1 ? string : string.pluralize end
and use it in your view:
<%= pluralize_without_count('Vote', item.votes) %>
Source: https://habr.com/ru/post/1391017/More articles:How to enable alpha blending in DirectX? - directxDoes ember.js support an ObjectController? If not, what replaces it? - javascriptSQL nested order? - sqllinked iterator check in Release mode (C ++) - c ++How to get a mechanism for automatically converting a body to UTF8? - ruby ββ| fooobar.comDoes my phone have a front camera AND / OR microphone? - c #Django / Python update field values ββ(while saving the model) - pythonChart Get a comment on the public message - facebookWeb Service Authentication in Java EE - java-eeRails: how to display image from download - ruby-on-railsAll Articles