我试过了:
class MyMailer
def routes
Rails.application.routes.url_helpers
end
def my_mail
@my_route = routes.my_helper
... code omitted
end
也在邮件中:
include Rails.application.routes.url_helpers
def my_mail
@my_route = my_helper
另外,简单的方法,在邮件模板中:
= link_to 'asd', my_helper
但是当我尝试启动控制台时,我得到:
undefined method `my_helper' for #<Module:0x007f9252e39b80> (NoMethodError)
更新
我正在使用_url
助手的形式,即my_helper_url