Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined method pluralize for main:Object

I'm trying to test a method in my console, but even the basic pluralize -

pluralize(1, 'person')

wont work..

Output:

NoMethodError: undefined method 'pluralize' for main:Object
from (pry):42:in '<main>'

but helper.method(:pluralize) shows me : Method: ActionView::Base(ActionView::Helpers::TextHelper)#pluralize

What am i missing?

like image 822
Mini John Avatar asked Jul 31 '14 14:07

Mini John


1 Answers

The helpers aren't included by default in the console. You can include them first and it'll work:

>> include ActionView::Helpers::TextHelper
>> pluralize(1, 'person')
# => "1 person"

Or, you can use the helper object which Rails gives you in the console:

>> helper.pluralize(1, 'person')
# => "1 person"
like image 125
Dylan Markow Avatar answered Nov 03 '22 09:11

Dylan Markow