0
0
Ruby on Railsframework~20 mins

Config folder purpose in Ruby on Rails - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Rails Config Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Purpose of the config folder in Rails
What is the main purpose of the config folder in a Rails application?
AIt stores configuration files that set up the application environment and settings.
BIt contains all the database migration files for schema changes.
CIt holds the view templates for rendering HTML pages.
DIt stores the user-uploaded files and assets.
Attempts:
2 left
💡 Hint
Think about where Rails keeps files that control app settings and environment.
component_behavior
intermediate
1:30remaining
Effect of changing config/environments/production.rb
If you modify config/environments/production.rb in a Rails app, what will happen when you deploy to production?
AThe changes will only apply after restarting the Rails server in development.
BThe production environment will use the new settings defined in that file.
CThe development environment will be affected instead of production.
DNo effect, because this file is ignored by Rails.
Attempts:
2 left
💡 Hint
Each environment file controls settings for that specific environment.
📝 Syntax
advanced
2:00remaining
Correct syntax for database config in config/database.yml
Which option shows the correct YAML syntax for defining the default database adapter as PostgreSQL in config/database.yml?
Adefault: adapter: postgresql
Bdefault = { adapter: 'postgresql' }
C
default:
  adapter: postgresql
Ddefault: { adapter: postgresql }
Attempts:
2 left
💡 Hint
YAML uses indentation and colons for key-value pairs.
🔧 Debug
advanced
2:00remaining
Why does Rails ignore changes in config/initializers?
You changed a file in config/initializers but your Rails app does not reflect the change after reload. Why?
AInitializers are only loaded once when the server starts, so you must restart the server.
BInitializers are cached in the browser and need cache clearing.
CInitializers only run in development, not in production.
DInitializers require a database migration to take effect.
Attempts:
2 left
💡 Hint
Think about when initializers run in the Rails lifecycle.
state_output
expert
2:30remaining
Output of Rails config after modifying config/application.rb
Given this snippet in config/application.rb:
module MyApp
  class Application < Rails::Application
    config.time_zone = 'Eastern Time (US & Canada)'
  end
end
What will Rails.application.config.time_zone return at runtime?
ARaises NoMethodError
B'UTC'
Cnil
D'Eastern Time (US & Canada)'
Attempts:
2 left
💡 Hint
The config.time_zone setting sets the app's time zone.