Their are 3 Rails Environments development, production, development. You can change between them by writing the following code inside your ~/.basrc or ~/.bash_profile
export RAILS_ENV="production" or export RAILS_ENV="development" or export RAILS_ENV="test"
for the respected environment. Or if you don’t want to change the environment just simply want to run the project on the respected environment then you can use this:
$rails db:migrate RAILS_ENV=production $rails server -e production
$rails db:migrate RAILS_ENV=development $rails server -e development
$rails db:migrate RAILS_ENV=test $rails server -e test