Using humanize to convert numeric into words in rails

2.1k Views Asked by At

I have some amount in numeric for e.g 75.00 and I am trying to convert it into words, for that I used humanize

75.humanize

But it keeps throwing error "undefined method humanize error for 75:Float"

1

There are 1 best solutions below

0
Deepak Mahakale On

Make sure you have installed humanize gem

Now you can convert number to words

2.humanize     #=> "two"
4.humanize     #=> "four"
8.humanize     #=> "eight"

75.humanize    #=> "seventy-five" 
75.0.humanize  #=> "seventy-five point zero" 
75.00.humanize #=> "seventy-five point zero" 

NOTE: Rails also has a humanize method in string class which works differently