GVS GVS - 7 months ago 40
Ruby Question

How to pluralize this sentence?

I am trying to display the number of followers a user has.

My original code was

<h5><%= current_user.followers.count %> followers<h5>

This produces the incorrect statement: "1 followers"

How to pluralize this sentence? I experimented with the following and I can't get it to work.

<%= 'follower'.pluralize(current_user.followers.count) %>

This displays just the word "follower" and no number in front of it.



<%= pluralize(current_user.followers.count, 'follower') %>

See http://apidock.com/rails/ActionView/Helpers/TextHelper/pluralize