I'm using rails 4.2.5.
And in rails API (for v4.2.5.2) I see this helper:
number_to_delimited(number, options = {})
Formats a number with grouped thousands using delimiter (e.g., 12,324). You can customize the format in the options hash.
http://api.rubyonrails.org/classes/ActiveSupport/NumberHelper.html#method-i-number_to_delimited
But when I using this help in my views, it throws an error:
undefined method
number_to_delimited' for #<#:0x0000000b091b30>`
Other helpers, such like number_to_currency
, all works well. What's wrong with me?
Try to call ActiveSupport::NumberHelper
instead.
ActiveSupport::NumberHelper.number_to_delimited(12345678)
=> "12,345,678"
Or you could do also with this:
include ActiveSupport::NumberHelper
number_to_delimited(12345678)
=> "12,345,678"
UPDATE:
I see you said in comment above that you're using haml code and you can do it like:
= ActiveSupport::NumberHelper.number_to_delimited(12345678)
Or
- include ActiveSupport::NumberHelper
= number_to_delimited(12345678)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With