Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to use pluralize() inside a model rather than a view?

It seems pluralize only works within a view -- is there some way that my models can use pluralize too?

like image 421
jpw Avatar asked Jul 24 '11 11:07

jpw


2 Answers

Rather than extend things, I just it like this:

ActionController::Base.helpers.pluralize(count, 'mystring') 

Hope this helps someone else!

like image 148
Tom Rossi Avatar answered Oct 03 '22 23:10

Tom Rossi


Add this to your model:

include ActionView::Helpers::TextHelper 
like image 26
Sam Ruby Avatar answered Oct 03 '22 23:10

Sam Ruby