It seems pluralize only works within a view -- is there some way that my models can use pluralize too?
It seems pluralize only works within a view -- is there some way that my models can use pluralize too?
This worked for me in rails 5.1 (see 2nd method, first method is calling it.)
# gets a count of the users certifications, if they have any.
def certifications_count
@certifications_count = self.certifications.count
unless @certifications_count == 0
return pluralize_it(@certifications_count, "certification")
end
end
# custom helper method to pluralize.
def pluralize_it(count, string)
return ActionController::Base.helpers.pluralize(count, string)
end