Challenge - 5 Problems
Rails Environment Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
How does Rails select environment configuration?
In a Rails app, when you run
rails server without specifying an environment, which environment configuration file does Rails load by default?Attempts:
2 left
💡 Hint
Think about which environment is used when you start the server locally for development.
✗ Incorrect
By default, Rails runs in the development environment when you start the server without specifying otherwise. So it loads config/environments/development.rb.
📝 Syntax
intermediate2:00remaining
Identify the syntax error in environment config
Which option contains a syntax error in a Rails environment configuration file?
Ruby on Rails
Example snippet: Rails.application.configure do config.cache_classes = true config.eager_load = true config.consider_all_requests_local = false end
Attempts:
2 left
💡 Hint
Look for misplaced keywords or missing line breaks.
✗ Incorrect
Option B has end on the same line without proper separation, causing a syntax error.
❓ state_output
advanced2:00remaining
What is the value of config.cache_classes in test environment?
Given the default Rails environment files, what is the value of
config.cache_classes in config/environments/test.rb?Attempts:
2 left
💡 Hint
Test environment is optimized for speed and consistency.
✗ Incorrect
In the test environment, config.cache_classes is set to true to avoid reloading classes and speed up tests.
🔧 Debug
advanced2:00remaining
Why does Rails load wrong environment config?
You run
rails server -e production but Rails still loads development settings. What is the most likely cause?Attempts:
2 left
💡 Hint
Environment variables have priority over command flags.
✗ Incorrect
If the RAILS_ENV variable is set to development, it overrides the -e production flag, causing Rails to load development config.
🧠 Conceptual
expert2:00remaining
Why separate environment config files in Rails?
Why does Rails use separate files like
development.rb, test.rb, and production.rb instead of one config file for all environments?Attempts:
2 left
💡 Hint
Think about how development and production differ in purpose and constraints.
✗ Incorrect
Separate files let Rails use tailored settings for development, testing, and production, improving performance, security, and debugging.