Project Anatomy & Startup
How a Rails app is created, laid out and started: rails new options, directory and naming conventions, boot, Zeitwerk autoloading and upgrades. Interviewers use it to test real project experience.
part ofRuby on Railsread it →on this pageshowhide
explore
- New App Options6 questions
- Default Directory Tree5 questions
- Doctrine & Naming Rules6 questions
- Middleware Stack & Dispatch4 questions
- Initializers & Load Order5 questions
- Autoloading & Reloading5 questions
- Upgrade Path & Defaults5 questions
questions
page 2 of 2In Rails 8.1, how do config.active_support.deprecation, disallowed_deprecation_warnings and Rails.application.deprecators help keep the next upgrade cheap?
basics
~10 sconfig.active_support.deprecation picks how warnings are reported; disallowed_deprecation_warnings with disallowed_deprecation = :raise turns chosen warnings into errors; Rails.application.deprecators applies both to every framework deprecator and to ones you register.
In Rails 8.1, what do ActionDispatch::Executor and ActionDispatch::Reloader do for each request, and when must you wrap code yourself?
basics
~20 sActionDispatch::Executor wraps every request in the app's executor, whose callbacks enable the query cache, release database connections and reset Current attributes. ActionDispatch::Reloader, present only when reloading is on, reloads changed code first. Threads you start need Rails.application.executor.wrap.
In a Rails 8.1 parcel-tracking app, how would you insert a request-timing middleware ahead of the session store, and what can break?
basics
~20 sCall config.middleware.insert_before ActionDispatch::Session::CookieStore, ParcelTimer in config/application.rb and confirm with bin/rails middleware. It breaks when the anchor class is absent in some environment (boot fails), when you edit the stack after boot, or when a reloadable class goes stale.
How would you set a Rails upgrade cadence for a portfolio of a dozen Rails apps, given Rails' six-month releases and support windows?
basics
~20 sAnchor the policy to Rails' windows: every app must stay on a security-supported minor and the latest patch, and most should follow each new minor within a set period. Deprecation ratchets, a next-Rails CI build and a shared playbook keep each step small.
In Rails 8.1, what does `rails new --devcontainer` generate, and how does the containerised app reach its PostgreSQL database?
basics
~10 srails new --devcontainer writes .devcontainer/devcontainer.json, a Dockerfile and compose.yaml; with -d postgresql, compose adds a postgres service, devcontainer.json sets DB_HOST to it, and database.yml reads DB_HOST as the host.
In a Rails 8.1 app, what do Rails.autoloaders.main.collapse and Rails.autoloaders.main.ignore change, and when would you use each?
basics
~20 scollapse keeps a directory managed but stops it from being a namespace, so app/models/filings/motion.rb defines Motion. ignore removes files or directories from Zeitwerk entirely, so they are neither autoloaded nor eager loaded and must be required by hand.
showing 31–36 of 36