Created
March 15, 2012 17:30
-
-
Save anoiaque/2045480 to your computer and use it in GitHub Desktop.
Use ENV to set database connection in rails
This file contains hidden or 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
#In an initializer | |
def ENV.[]= key, value | |
if key == 'RAILS_DATABASE_CONNECTION' | |
ActiveRecord::Base.establish_connection (JSON.parse(value)) | |
end | |
store(key, value) | |
end | |
ENV["RAILS_DATABASE_CONNECTION"] = %Q{{"database":"foo","adapter":"sqlite3"}} #... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment