You need to setup a separate environment. By default in a new project rails sets up test, production and development. You need to setup development_2 or staging or whatever adequately describes what you're doing.
In your rails project in config/environments
copy the development file to a new file with the name you're using for your environment.
Then in your database.yml
file, make sure there is an entry named to match each environment. So if you have development and development_2 then your entries should be:
development:
adapter: mysql2
host: localhost
database: db1
user: root
password: asdf
pool: 5
timeout: 5000
development_2:
adapter: mysql2
host: localhost
database: db2
user: root
password: asdf
pool: 5
timeout: 5000
By default when you run a rails application it will be in development, so that is already selecting the development
database from your yml file.
Now when you want to run in an alternative environment you'll just tell rails the env is development_2
, if you're using the rails server
command it will instead be
rails server -e development_2
Note that this new environment might break certain gems which are hard carded to work for only staging
, test
, production
and development
.