How can I start the rails console and use the testing database exclusively?

ruby-on-rails

Solution

To start console in `test` environment:

ruby script/console test 
ruby script/console production 

To run rake tasks in `test` environment:

rake db:create RAILS_ENV=test 
rake db:migrate RAILS_ENV=test 

In Rails 3 and 4 you can use:

rails console test
rails c test

In Rails 5 you can use:

rails console -e test
rails c -e test

Problem

I'd like to start the rails console and create database entries in a database that isn't the default database, such as the testing database. I'd appreciate any help.

Original source

Related problems