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 the 88 expected users in PGadmin in the inspector_development database on osx. However, even after restarting the rails app, the User table still shows only one user, not the 88 I see in PGadmin.
I've googled for how to determine what Rails sees as the properties of the database name in order to determine where is it finding these non-existent records?
Looking more closely at the User table in PGadmin I see zero columns. Perhaps PGadmin is mistaken? I'm unable to determine where the db Rails is looking for so that I can troubleshoot this, thx, sam
You can use rails dbconsole to view the database that your rails application is using. It's alternative answer rails db . Both commands will direct you the command line interface and will allow you to use that database query syntax.
Rails defaults to using a SQLite database when creating a new project, but you can always change it later.
This works in Rails 3 and Rails 4
ActiveRecord::Base.connection.current_database
But this only works with drivers that have implemented that method. For example, it will not work for SQLite but will work with mysql and postgres.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With