rails7-startkit icon indicating copy to clipboard operation
rails7-startkit copied to clipboard

database that was last run in `development`

Open the-teacher opened this issue 2 years ago • 2 comments

rspec -f documentation

ActiveRecord::EnvironmentMismatchError: You are attempting to modify a database that was last run in `development` environment.
You are running in `test` environment. If you are sure you want to continue, first set the environment using:

        bin/rails db:environment:set RAILS_ENV=test


Tasks: TOP => db:test:load => db:test:purge => db:check_protected_environments
(See full trace by running task with --trace)
Screenshot 2023-02-10 at 21 58 13

the-teacher avatar Feb 10 '23 18:02 the-teacher

Hello @the-teacher if you are using windows run this command => rails db:environment:set RAILS_ENV=test, and if you are using a different OS you can run this command bin/rails db:environment:set RAILS_ENV=test

ibr5500 avatar Mar 07 '23 17:03 ibr5500

This problem only shows when you are testing, Ruby on Rails has different databases for development, testing, and production.

ibr5500 avatar Mar 07 '23 17:03 ibr5500