Forum: Ruby on Rails Delayed_Job and Setting Env

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
sshefer (Guest)
on 2009-03-19 09:50
(Received via mailing list)

I am setting up a background task using delayed job to upload some of
my documents up to scribd from my S3 bucket.

The problem I encounter is that I get an error saying:
Job failed with RightAws::AwsError: AWS access keys are required to
operate on S3

I realize that this is because my job doesn't know what environment
I'm in so I explicitly set it in the class (ENV['RAILS_ENV'] =
"development").  There has to be a better way of doing this so that I
don't need to to change this every time.

Is there a better way of doing this?  Am I not putting this in the
right place?


============= Code Snippet Below =============

class Job (in lib/script_job.rb)
  attr_accessor :document_id

  ENV['RAILS_ENV'] = "development"

  def initialize(document)
    self.document_id =

  def perform
    document = Document.find(document_id)
    Scribd::API.instance.key = APP_CONFIG[:scribd_api_key]
    Scribd::API.instance.secret = APP_CONFIG[:scribd_api_secret]
    Scribd::User.login APP_CONFIG[:scribd_user], APP_CONFIG
    upload = Scribd::Document.upload(:file => document.s3_url,
                                     :type => return_doc_type
This topic is locked and can not be replied to.