How to find database name in rails console

This is odd. In my Rails 4 database.yml, I have the following:

development: adapter: postgresql encoding: unicode database: inspector_development password: pool: 5 

I copied the production database from Heroku and imported it using this form into my local copy of Postgresql

 curl -o latest.dump `heroku pgbackups:url --account personal` pg_restore --verbose --clean --no-acl --no-owner -h localhost -U sam -d inspector_development latest.dump 

The result showed 88 expected users in PGadmin in the osx inspector_development database. However, even after restarting the rails application, only one user is shown in the User table, not 88, which I see in PGadmin.

I was looking for information on how to determine what Rails sees as database name properties to determine where to find these non-existent entries?

Having examined the User table in PGadmin more closely, I see null columns. Perhaps Pgadmin is mistaken? I cannot determine where db Rails is looking so that I can fix this problem, thanks, sam

+6
source share
1 answer

This works in Rails 3 and Rails 4

 ActiveRecord::Base.connection.current_database 

But this only works with drivers that have implemented this method. For example, it will not work for SQLite, but it will work with mysql and postgres.

+10
source

Source: https://habr.com/ru/post/985968/


All Articles