dimanche 28 juin 2015

ActiveRecord::Base.establish_connection with postgresql on AWS

When got my database.yml configured like this:

default: &default
  adapter: postgresql
  encoding: utf8
  pool: 5
  timeout: 5000

production:
  <<: *default
  host: my_db_address
  port: 5432
  database: my_db_name
  username: my_db_user_name
  password: my_db_password

< test and development ommited >

When I establish connection like this:

ActiveRecord::Base.establish_connection

it says ActiveRecord::AdapterNotSpecified - 'production'

It works hovewer If I do it like this: ActiveRecord::Base.establish_connection( {:adapter => 'postgresql', :database => 'my_db_name', :host => 'my_db_address', :port => '5432', :username => 'my_db_user_name', :password => 'my_db_password'} )

I'd rather load the config from database.yml. How do I do this?

I'm on Rails 4.2.1 and Postgres 9.4




Aucun commentaire:

Enregistrer un commentaire