P
prepair.app
Start interview →
EnglishУкраїнськаРусский
💎

Senior Ruby on RailsRuby on Rails interview questions

Senior · 5+ years of experience

Ruby interviews go two layers deep: the language itself — blocks, modules, the method lookup chain — and then Rails, where most questions are really about ActiveRecord and the database underneath it. Below are the questions asked most often, each with a model answer. Senior: architecture, trade-offs, mentoring, and decision-making.

Topics to prepare

Ruby core and blocks
OOP, modules and mixins
ActiveRecord and associations
Rails MVC, routing, controllers
N+1 queries and performance
RSpec, FactoryBot, Rubocop

5 Senior-level questions with answers

1

How do you run a migration on a large table without downtime?

Answer

Assume the table is locked for as long as the statement takes, and shape the change so it is not. Add columns as nullable without a default, backfill in batches outside the migration, add indexes concurrently, and only then add the constraint. Renaming and dropping are the dangerous ones because old code is still running during the deploy — do them in two releases with a dual-write in between.

2

How do you break up a Rails monolith that has grown too big?

Answer

Draw the boundaries before extracting anything — usually along the parts of the domain that change together. Enforce them inside the same codebase first, with modules or engines and no cross-boundary database access, which is where you learn the boundary was wrong at almost no cost. Extracting a service is the last step, not the first, and it is only worth it when a team or a scaling need actually demands it.

3

When is metaprogramming worth it, and what does it cost?

Answer

It pays off in a small library where it removes a large amount of repetition — define_method over a list of attributes is fine. It costs at the point where someone greps for a method name and finds nothing, or where a typo becomes a silent nil because method_missing swallowed it. If you define method_missing, define respond_to_missing? with it, otherwise the object lies about what it can do.

4

How do you decide what to cache?

Answer

Cache what is expensive and stable, and only after the query is already as good as it will get — caching is not a fix for an N+1, it is a way of hiding one until the cache misses. Decide the invalidation before the caching: a key that includes updated_at expires itself, whereas a manual sweep is the thing that will be forgotten. Cached wrong data is worse than a slow page.

5

How do you approach a major Rails upgrade on a live product?

Answer

Get the test suite honest first, because the upgrade is only as safe as what it can tell you. Then go one minor version at a time, deal with deprecation warnings before they become errors, and keep the app running on the old and new versions in the same branch where the framework allows it. The part people underestimate is gems: the blocker is usually an unmaintained dependency, not Rails itself.

🦎

Reading answers is not enough

In a real interview you speak under pressure. Cam asks these same questions, scores every answer, and shows exactly what to fix.

Practice a Senior Ruby on Rails interview →
Free · 3 interviews per month

Other levels — Ruby on Rails

Junior Ruby on RailsMiddle Ruby on RailsAll Ruby on Rails questions

Other specializations

🔍Senior Manual QA🤖Senior QA AutomationSenior Java Backend🐍Senior Python Backend🐘Senior PHP Backend🦫Senior Go Backend🟢Senior Node.js Backend🔷Senior C++🟨Senior JavaScript⚛️Senior React Frontend