I need to know which environment and database my migration is running
for.
I can read RAILS_ENV
How do I lookup my environment in database.yml?
Thanks for any help
I need to know which environment and database my migration is running
for.
I can read RAILS_ENV
How do I lookup my environment in database.yml?
Thanks for any help
Desert P. wrote:
I need to know which environment and database my migration is running
for.I can read RAILS_ENV
How do I lookup my environment in database.yml?
Thanks for any help
I figured it out:
y =
YAML::load(ERB.new((IO.read("#{RAILS_ROOT}/config/database.yml"))).result)
db = y[RAILS_ENV][“database”]
ActiveRecord::Base.configurations also already has what you seek loaded.
Gabriel Gironda wrote:
ActiveRecord::Base.configurations also already has what you seek loaded.
- Gabriel
Thanks for the tip - can you post an example for this?
I can’t seem to find any documentation after googling…
Thanks
On May 23, 7:02 am, Desert P. [email protected]
wrote:
Gabriel Gironda wrote:
ActiveRecord::Base.configurations also already has what you seek loaded.
- Gabriel
Thanks for the tip - can you post an example for this?
I can’t seem to find any documentation after googling…
console is your best friend in such cases
just give it
ActiveRecord::Base.configurations
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs