4

So if I try sending an email with action mailer directly, I can use all application helpers like url_for, content_for etc, but when I try to do the exact same action [sending email] with delayed_job [send_later] I getting a delayed job fail, of undefined function content_for etc, so it is like no helpers are loaded in my ActionMailer. I am using rails 2.3.8, active_mailer 2.3.8 and delayed_job 2.0.3

Thanks!!

David Moles
  • 48,006
  • 27
  • 136
  • 235
Savvas
  • 41
  • 1

1 Answers1

0

Your problem is that your sw is not a child of ActionView since your sw is not being initiated as a result of a web request. Rather, your sw is being initiated by the DelayedJob machinery.

Solution: create and use your own instance of ActionView --

action_view = ActionView::Base.new # used for calling helper tags, eg link_to
html = action_view.link_to(link_text, url)
# etc...
Larry K
  • 47,808
  • 15
  • 87
  • 140