0
0
Ruby on Railsframework~20 mins

Environment configuration files in Ruby on Rails - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Rails Environment Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2: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?
Aconfig/environments/development.rb
Bconfig/environments/test.rb
Cconfig/environments/production.rb
Dconfig/application.rb
Attempts:
2 left
💡 Hint
Think about which environment is used when you start the server locally for development.
📝 Syntax
intermediate
2: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
Aconfig.eager_load = true
Bconfig.consider_all_requests_local = false end
Cconfig.consider_all_requests_local = false
Dconfig.cache_classes = true
Attempts:
2 left
💡 Hint
Look for misplaced keywords or missing line breaks.
state_output
advanced
2: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?
Aundefined
Bfalse
Cnil
Dtrue
Attempts:
2 left
💡 Hint
Test environment is optimized for speed and consistency.
🔧 Debug
advanced
2: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?
ARails does not support -e flag for environment selection
BYou forgot to restart the server after changing environment
CThe RAILS_ENV environment variable is set to development overriding the flag
Dconfig/environments/production.rb file is missing
Attempts:
2 left
💡 Hint
Environment variables have priority over command flags.
🧠 Conceptual
expert
2: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?
ATo allow different settings optimized for each environment's needs and security
BBecause Rails cannot parse a single file with multiple environment blocks
CTo prevent sharing any configuration between environments
DTo force developers to write more code and increase complexity
Attempts:
2 left
💡 Hint
Think about how development and production differ in purpose and constraints.