Add the named route to config / routes.rb and then call it from your job class (no need to include anything)
Rails.application.routes.url_helpers.following_user_url(following_user)
You must also set the default host in your environment, since you are inside a "resque" and there are no http parameters set.
routes.default_url_options = {:host => "somehost.com"}
Alternatively, you can include url_helpers and do something like this in your class
class SoulmateUserFollowing include Rails.application.routes.url_helpers @queue = :soulmate_user def initialize(user_id) user = User.find(user_id) url = url_for(following_user) end def self.perform(user_id) new(user_id) end end
source share