Created
August 9, 2011 22:36
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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