Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the pluralize method in a rake task

I know this seems silly, but I would like to call some of Rails' Text Helpers in a rake task I am setting up. (Thinks like the pluralize and cycle method: http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html)

How would you go about making these available in a rake task, or is it not easily possible?

like image 304
Scott Swezey Avatar asked Dec 30 '09 23:12

Scott Swezey


1 Answers

It's rather messy to extend ActionView::Helpers in your rake task - that basically includes all helper methods in your Rake task.

ActionController::Base.helpers.pluralize(5, 'dog')

If you don't have a count and you just want to pluralize a word:

ActiveSupport::Inflector.pluralize('dog')

like image 133
Jaco Pretorius Avatar answered Oct 15 '22 18:10

Jaco Pretorius