【发布时间】:2013-06-16 16:31:24
【问题描述】:
我有一个自定义帮助模块,CalendarHelper。然后我的一些视图使用自定义辅助方法来显示日历。
当我尝试在我的自定义助手中使用任何视图助手时,例如 number_to_currency(),我得到一个未定义的方法错误,即使我添加了
include ActionView::Helpers::NumberHelper
给我的日历助手。
我也尝试向 application_helper 添加一个方法:
def as_dollars_pretty(price)
number_to_currency(price, :precision => 2, :unit => '$')
end
然后在我的自定义助手中添加了
include ApplicationHelper
但是当我尝试在我的自定义日历助手中使用 as_dollars_pretty(123.45) 时,我得到了相同的未定义方法错误。
【问题讨论】:
标签: ruby-on-rails ruby helper