Reputation: 19257
I have a custom helper module, CalendarHelper. Some of my views then use custom helper methods to display a calendar.
When I try to use any view helpers inside my custom helpers, such as number_to_currency(), I get an undefined method error, even if I add
include ActionView::Helpers::NumberHelper
to my CalendarHelper.
I also tried adding a method to application_helper:
def as_dollars_pretty(price)
number_to_currency(price, :precision => 2, :unit => '$')
end
then in my custom helper I added
include ApplicationHelper
but when I try to use as_dollars_pretty(123.45) in my custom calendar helper I get the same undefined method error.
Upvotes: 1
Views: 315
Reputation: 16730
This works for me
module TestHelper
include ActionView::Helpers::NumberHelper
def foo
number_to_currency 123
end
end
include TestHelper
puts foo
Upvotes: 2