Skip to content

Instantly share code, notes, and snippets.

@heycarsten
Created August 9, 2011 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heycarsten/1135389 to your computer and use it in GitHub Desktop.
Save heycarsten/1135389 to your computer and use it in GitHub Desktop.
A moderately hacky way of generating a PG connection string from AR::Base.configurations to use with QueueClassic
ENV['DATABASE_URL'] ||= lambda {
def config
ActiveRecord::Base.configurations[Rails.env.to_s]
end
def credentials
if (creds = [config['user'], config['password']]).any?
creds.join(':')
else
nil
end
end
def host
if (h = config['host']).present?
h
else
'localhost'
end
end
[].tap { |a|
a << 'postgres://'
a << credentials + '@' if credentials
a << host
a << ':' + config['port'] if config['port']
a << '/' + config['database']
}.join
}.()
EmailQueue = QC::Queue.new('qc_email_jobs')
ImageQueue = QC::Queue.new('qc_image_jobs')
TranscodingQueue = QC::Queue.new('qc_transcoding_jobs')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment