Ruby on Rails
Rails is a full-stack web framework built on Ruby: routing, an ORM, view rendering, background jobs, WebSockets, mailers and a test harness, all shipped together and all expected to work with each other. That integration is the point. A Rails application is less a set of libraries you assemble and more a shape you fill in.
Most Rails interview questions are not about Rails. They are about the consequences of the two decisions below — what happens when convention is wrong, when the ORM hides a query, when the callback you did not know about fires.
The 60-second answer
Section titled “The 60-second answer”“Rails is MVC plus convention over configuration. The router maps a URL to a controller action; the controller loads models, applies business rules and assigns instance variables; the view renders those variables to HTML. Conventions — PostsController lives in app/controllers/posts_controller.rb, the table for Post is posts, the primary key is id — remove the configuration files other frameworks need. Active Record maps rows to objects but does not hide SQL, so the real skill is knowing which Ruby line becomes which query. The framework is opinionated, so the useful senior signal is knowing where the opinions stop working: business logic that does not fit a model, queries that N+1, callbacks that cascade.”
Convention over configuration
Section titled “Convention over configuration”| Convention | What it saves you |
|---|---|
| File paths mirror class names | No autoload registry; Zeitwerk resolves Admin::User to app/models/admin/user.rb |
| Table name is the pluralised, underscored class name | No mapping file; LineItem → line_items |
resources :posts gives seven RESTful routes |
No route table to design per resource |
Foreign key is <association>_id |
belongs_to :author reads author_id |
index action renders posts/index.html.erb |
No template declaration |
_form.html.erb is the partial for form |
render "form" finds it |
The flip side: when you deviate you pay in configuration, and a reader who does not know the convention cannot follow the code. self.table_name = "legacy_orders" is legitimate but it is a cost, not a style choice.
What Rails gives you
Section titled “What Rails gives you”- Action Pack — routing, controllers, views, helpers, filters.
- Active Record — the ORM: models, migrations, associations, validations, callbacks.
- Active Model — validations and dirty tracking for objects that are not database-backed.
- Active Job — one interface over Sidekiq, GoodJob, Solid Queue and friends.
- Action Cable — WebSockets integrated with the same models and channels.
- Action Mailer / Active Storage / Action Text — email, uploads, rich text.
- Turbo and Stimulus — the Hotwire default front end, no separate SPA required.
- Rake tasks, generators, credentials, a test harness — the operational scaffolding.
Rails 8 ships Solid Queue, Solid Cache and Solid Cable as database-backed defaults, which means a small application needs no Redis at all. That is a meaningful change to the “you must run Redis” assumption in older interview answers.
How this section is organised
Section titled “How this section is organised”- MVC in Rails — request lifecycle, where business logic belongs, service and form objects.
- Active Record — associations, migrations, validations, callbacks, STI, N+1, transactions, locking.
- Routing — resources, nesting, namespaces, constraints, shallow routes.
- Controllers and Views — actions, filters, strong parameters, sessions, layouts, partials, escaping.
- Active Job and Action Cable — background work and WebSockets, including idempotency and scaling.
- Hotwire and Turbo — Drive, Frames, Streams, Stimulus.
- Rails Engines — packaging a slice of an application as a mountable component.
- Testing Rails — RSpec, factories, request and system specs, transactional tests.
- Rails Performance — N+1, indexes, caching, pagination, profiling.
- Rails Security — CSRF, XSS, mass assignment, secrets, dependency auditing.
- Rails: Pros and Cons — the honest trade-offs, including the scalability myth.
- Rails Interview Questions — the questions that actually come up, with answers.
If your Ruby itself is shaky, read the Ruby track first: blocks, modules and method_missing are what Rails DSLs are made of.
Follow-up questions
Section titled “Follow-up questions”- What exactly does Zeitwerk do, and what breaks when a file is in the wrong directory?
- Which parts of Rails would you remove for a JSON API, and what do you keep?
- Where does Rails’ “magic” actually live — what mechanism implements it?
- Why is
ApplicationRecordan abstract class rather thanActiveRecord::Basedirectly? - What does
config.eager_loadchange between development and production?
Common traps
Section titled “Common traps”- “Rails is a language.” Ruby is the language. Rails is a gem set built on Rack.
- “Convention over configuration means no configuration.” It means defaults you can override, not an absence of decisions.
- “Active Record means you never write SQL.” It means you rarely write it — and every inefficiency you ship is still SQL.
- “Rails cannot scale.” Rails scaled GitHub, Shopify and Basecamp. What does not scale is a codebase with no boundaries, in any framework.
- “Rails is Rails 3.” Answers from 2012 (asset pipeline, observers,
attr_accessible) are wrong today and interviewers notice.
Further reading
Section titled “Further reading”- Rails Guides — the primary source; read the Active Record Query Interface and Associations guides end to end.
- The Rails Doctrine — DHH on the opinions, useful for arguing the trade-offs.
- Rails API documentation