Ruby on Rails Configuration Database Configuration

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Database configuration of a rails project lies in a file config/database.yml. If you create a project using rails new command and don't specify a database engine to be used then rails uses sqlite as the default database. A typical database.yml file with default configuration will look similar to following.

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
#
default: &default
  adapter: sqlite3
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: db/test.sqlite3

production:
  <<: *default
  database: db/production.sqlite3

If you want to change the default database while creating a new project you can specify database: rails new hello_world --database=mysql



Got any Ruby on Rails Question?