I am under:
ruby-1.9.3-p194
Rails 3.0.9
I would like to use in my view method percent_of with Numeric data type.
For example, <%= 10.persent_of(50) %> it's equal 20%.
to do that I have created lib/numeric.rb file that contains
class Numeric
def percent_of(n)
self.to_f / n.to_f * 100.0
end
end
But I got an error:
undefined method `percent_of' for 10:Fixnum
I was trying to add definition require 'Numeric' but it didn't help me.
Help me plz.
config/initializersinstead. That way you don't need to require it.