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?
✗ Incorrect
PostgreSQL is a powerful, reliable database that works well with Rails in production.
What does
RAILS_ENV=production rails db:create do?✗ Incorrect
This command creates the production database using the production settings.
Where should you store your production database password in Rails?
✗ Incorrect
Environment variables keep sensitive info safe and separate from code.
Which command runs database migrations in production?
✗ Incorrect
Adding
RAILS_ENV=production runs migrations on the production database.Why is SQLite not suitable for production in Rails?
✗ Incorrect
SQLite is designed for simple, local use and struggles with concurrent users.
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.