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

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)