0

I am running on Rails 3.1 RC5. Resque doesn't seem like it is able to access root_url from a worker class. I tried putting include Rails.application.routes.url_helpers to no avail.

For example:

module EncodePhoto
  include Rails.application.routes.url_helpers

  def self.perform()
    puts root_url
  end
end

Returns:

undefined method `root_url' for EncodePhoto:Module
Christian Fazzini
  • 19,613
  • 21
  • 110
  • 215

1 Answers1

0

If I am in a rails console, I can write:

include ActionController::UrlWriter

and then I can access the routes I need. Perhaps it can apply to your problem as well?

EDIT: Please see this. Here's the accepted answer from there:

include ActionDispatch::Routing::UrlFor
include ActionController::PolymorphicRoutes
include Rails.application.routes.url_helpers
default_url_options[:host] = 'example.com'
Community
  • 1
  • 1
Geo
  • 93,257
  • 117
  • 344
  • 520