1

I'm using sinatra and sidekiq together. I'm trying to render a erb template from within a sidekiq worker and i'm getting a undefined method 'erb'. In my head, things should work cause sidekiq is loaded up as an instance of my sinatra app, so it should have the erb method. What am i missing here?

class SomeWorker
  include Sidekiq::Worker

  def perform(id)
    erb(:emailTemplate)
  end
end

(i now realized the SomeWorker class has nothing to to do with sinatra and so of course it doesn't have the erb method. maybe i can just make a call out to helper module? in place of the erb method call?)

4

1 回答 1

0

所以我想出了1个解决方案:

require 'erb'
require 'tilt'

class ForgotEmailWorker
  include Sidekiq::Worker

  def perform
    template = tilt.new(__path_to_erb_file).render
  end
end
于 2013-11-05T17:50:14.627 回答