config.cache_classes = true in production?config.cache_classes = true do?Setting config.cache_classes = true in production tells Rails to load application classes once and cache them. This avoids reloading classes on every request, which improves performance.
The correct syntax uses ENV['RAILS_SERVE_STATIC_FILES'].present? to check if the environment variable is set and assigns a boolean accordingly.
config.log_level after this production config runs?config/environments/production.rb:
Rails.application.configure do config.log_level = :info config.log_level = :debug if ENV['DEBUG_LOG'] == 'true' endIf the environment variable
DEBUG_LOG is not set, what is the final value of config.log_level?If ENV['DEBUG_LOG'] is not set, the condition ENV['DEBUG_LOG'] == 'true' is false, so config.log_level remains :info.
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?In Ruby hashes, commas are required between key-value pairs. Missing commas after address: 'smtp.example.com' and domain: 'example.com' cause syntax errors.
config.assets.digest = true enables fingerprinting of asset filenames, which helps browsers cache assets effectively. This is standard in production.