Search code examples
ruby-on-railsruby-on-rails-3ruby-on-rails-3.1pluralizeplural

Pluralize in Rails View Issues


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.


Solution

  • You can do:

    pluralize(items.votes, 'Vote').split(" ", 2)[1]
    

    Hope that helps!