0
0
Ruby on Railsframework~5 mins

Database setup for production in Ruby on Rails - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the config/database.yml file in a Rails production setup?
It defines the database connection settings for different environments, including production. This file tells Rails how to connect to the production database with details like adapter, host, username, password, and database name.
Click to reveal answer
beginner
Why should you avoid using SQLite in a Rails production environment?
SQLite is designed for simple, local development and does not handle multiple users or heavy traffic well. Production environments usually use more robust databases like PostgreSQL or MySQL that support concurrency and scaling.
Click to reveal answer
beginner
What command do you run to create the production database in Rails?
You run RAILS_ENV=production rails db:create to create the production database using the settings in config/database.yml.
Click to reveal answer
beginner
How do you run migrations on the production database in Rails?
Use RAILS_ENV=production rails db:migrate. This applies all pending database changes to the production database.
Click to reveal answer
intermediate
What is the role of environment variables in Rails production database setup?
Environment variables store sensitive info like database passwords outside the code. Rails can read these variables to keep secrets safe and allow easy changes without editing code files.
Click to reveal answer
Which database adapter is commonly recommended for Rails production?
AMongoDB
BSQLite
CCSV files
DPostgreSQL
What does RAILS_ENV=production rails db:create do?
ACreates the development database
BCreates the test database
CCreates the production database
DDeletes the production database
Where should you store your production database password in Rails?
AIn environment variables
BHardcoded in <code>database.yml</code>
CIn a public GitHub repo
DIn the app's JavaScript files
Which command runs database migrations in production?
ARAILS_ENV=production rails db:migrate
Brails db:migrate
Crails db:rollback
Drails server
Why is SQLite not suitable for production in Rails?
AIt is too fast
BIt does not support multiple users well
CIt requires internet connection
DIt is not free
Explain the steps to set up a production database in a Rails application.
Think about configuration, security, and commands.
You got /4 concepts.
    Why is it important to separate production database credentials from your code in Rails?
    Consider risks of hardcoding secrets.
    You got /4 concepts.