Trip
Trip

Reputation: 27114

Is it possible to import helpers into a Resque worker?

My worker is sending out an email. And the email requires helpers.

For some reason those helpers are inaccessible within the email if Resque handles it.

How can I import the Helpers?

Would I do it through the partial itself, the controller, or the Resque worker?

Update

This only occurs when running tests.

Upvotes: 0

Views: 435

Answers (1)

ernd enson
ernd enson

Reputation: 1762

Upps, read the update too late. I don't know, if this helps for your tests.


You could do a call to to_prepare in your application.rb to get access to your helpers in the ActionMailer. Be sure to include it and call the helper method on it, to be able to call the helpers from within your mailer and your mailer's view templates.

config.to_prepare do
  ActionMailer::Base.class_eval do 
    include ApplicationHelper
    helper ApplicationHelper 
  end 
end

Upvotes: 1

Related Questions