I’m trying to return a sum using number_to_currency, but whenever I try to use this method inside a rake task or model class instance, I get NoMethodError: undefined method 'number_to_currency' for main:Object
Happens in console too. Any suggestions on why I can’t use basic methods inside rake tasks or models?
number_to_currencyis a view helper so it is generally only available within views. You could do this:inside a class if you need to use it somewhere else. Think twice about your design though, using a view helper while messing around in the console is fine but you usually want to push your formatting out to the edges (i.e. views).