Module: ActionView::Helpers::TextHelper

Defined in:
lib/brick/compatibility.rb

Instance Method Summary collapse

Instance Method Details

#pluralize(count, singular, plural_arg = nil, plural: plural_arg, locale: I18n.locale) ⇒ Object

Older versions of #pluralize lack the all-important .to_s



134
135
136
137
138
139
140
141
142
# File 'lib/brick/compatibility.rb', line 134

def pluralize(count, singular, plural_arg = nil, plural: plural_arg, locale: I18n.locale)
  word = if (count == 1 || count.to_s =~ /^1(\.0+)?$/)
    singular
  else
    plural || singular.pluralize(locale)
  end

  "#{count || 0} #{word}"
end