我有一个EmailHelper
定义在/lib/email_helper.rb
. 该类可以由控制器或后台作业直接使用。它看起来像这样:
class EmailHelper
include ActionView::Helpers::DateHelper
def self.send_email(email_name, record)
# Figure out which email to send and send it
time = time_ago_in_words(Time.current + 7.days)
# Do some more stuff
end
end
调用时time_ago_in_words
,任务失败并出现以下错误:
undefined method `time_ago_in_words' for EmailHelper
如何time_ago_in_words
从我的类的上下文中访问辅助方法EmailHelper
?请注意,我已经包含了相关模块。
我也试过打电话helper.time_ago_in_words
,ActionView::Helpers::DateHelper.time_ago_in_words
但无济于事。