Rails has nothing to do with where your db is stored
The fact it handles a local DB (for development) is co-incidental. The db needs to be stored in the most efficient, fastest & most scalable environment; which may, or may not, be local depending on your setup
Heroku
As you've cited Heroku in your tags, you need to know Heroku just uses Amazon AWS services, meaning your db will be stored in the same data center, but on a different computing platform
The way to access these db's is through a custom URL (check heroku config
- DATABASE_URL
to see where your Heroku db is stored). This means Rails can use either localhost (127.0.0.1:3000
) or an external IP to connect to the db
database.yml
The config/database.yml
file holds all the connection information for your app:
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: mysql
encoding: utf8
database: your_db
username: root
password: your_pass
socket: /tmp/mysql.sock
host: your_db_ip #defaults to 127.0.0.1
port: 3306
The 3 environments allow you to set different databases for development, production etc. Heroku is by default the "production" environment, although you can set it to the staging environment too
As long as your connection details are correct, you should be able to connect to any system