Reputation: 606
I want to use activerecord without rails. I know that in rails we can use the production mode as RAILS_ENV=production
but how do I use production mode in activerecord without rails?
Upvotes: 0
Views: 320
Reputation: 22926
APP_ENV=production
environment = ENV['APP_ENV'] || 'development' puts "Connecting to #{environment} database" ActiveRecord::Base.establish_connection YAML.load_file(config)[environment]
Upvotes: 1
Reputation: 2090
The way you connect to your database is up to you, you just have to supply the credentials. If you want to implement something like config/database.yml
without Rails you will have to do it yourself, and you can use an environment variable of your choice to specify which key in the file to read.
Upvotes: 0