0
0
Ruby on Railsframework~20 mins

Production environment configuration in Ruby on Rails - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Rails Production Pro
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
1:30remaining
What is the effect of setting config.cache_classes = true in production?
In a Rails production environment configuration, what does setting config.cache_classes = true do?
AIt reloads application classes on every request, slowing down response time.
BIt enables verbose logging of class loading for debugging purposes.
CIt caches application classes so they are loaded once, improving performance.
DIt disables class loading entirely, causing errors when classes are referenced.
Attempts:
2 left
💡 Hint
Think about how caching classes affects speed and memory in production.
📝 Syntax
intermediate
1:30remaining
Identify the correct syntax to enable serving static files in production
Which of the following lines correctly enables serving static files in a Rails production environment configuration file?
Aconfig.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
Bconfig.public_file_server.enabled == true
Cconfig.public_file_server.enabled = true if ENV['RAILS_SERVE_STATIC_FILES']
Dconfig.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES']
Attempts:
2 left
💡 Hint
Check how to properly assign a boolean based on environment variable presence.
state_output
advanced
1:30remaining
What is the value of config.log_level after this production config runs?
Given this snippet in config/environments/production.rb:
Rails.application.configure do
  config.log_level = :info
  config.log_level = :debug if ENV['DEBUG_LOG'] == 'true'
end
If the environment variable DEBUG_LOG is not set, what is the final value of config.log_level?
A:debug
B:info
Cnil
DRaises an error because ENV['DEBUG_LOG'] is nil
Attempts:
2 left
💡 Hint
Consider what happens when the environment variable is missing.
🔧 Debug
advanced
2:00remaining
Why does this production config cause an error?
Examine this production environment configuration snippet:
Rails.application.configure do
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address: 'smtp.example.com',
    port: 587,
    domain: 'example.com',
    user_name: ENV['SMTP_USER'],
    password: ENV['SMTP_PASS'],
    authentication: 'plain',
    enable_starttls_auto: true
  }
end
Why does this code raise a syntax error?
AMissing commas between some hash key-value pairs cause a syntax error.
BUsing symbols as keys in smtp_settings is not allowed in production config.
CThe delivery_method :smtp is invalid in production environment.
DENV variables cannot be used directly in production config files.
Attempts:
2 left
💡 Hint
Look carefully at punctuation between hash entries.
🧠 Conceptual
expert
2:30remaining
Which production config setting ensures assets are precompiled and digest filenames are used?
In Rails production configuration, which setting ensures that assets are precompiled and served with digest fingerprints for caching?
Aconfig.assets.precompile = false
Bconfig.assets.compile = true
Cconfig.assets.debug = true
Dconfig.assets.digest = true
Attempts:
2 left
💡 Hint
Think about how Rails manages asset filenames for caching in production.