Skip to content

Top 33 Ruby on Rails Interview Questions and Answers [2026]

November 16, 2026 29 min read
Ruby on Rails interview guide by Second Talent
TL;DR: Ruby on Rails interviews in 2026 test Active Record judgment (N+1 queries, transactions, safe migrations), the database-backed Solid Queue, Solid Cache and Solid Cable stack, Hotwire, and deploying with Kamal 2. The current release is Rails 8.1.4.1 (November 4, 2026), on Ruby 3.2 or newer, with Ruby 4.0 (December 25, 2025) now the newest stable Ruby.

Rails 8.0 lost security support on November 7, 2026, according to the Rails maintenance policy, so any team still on 8.0 now runs a series that gets no new releases.

The supported line is Rails 8.1.4.1, a security release that shipped alongside the final 8.0.5.2.

The 33 questions below are for senior Rails and full stack interviews, with four find-the-bug rounds and several design tradeoffs around the Solid adapters.

Key takeaways
  1. 1Rails 8.0 security support ended on November 7, 2026; Rails 8.1 gets security fixes until October 10, 2027.
  2. 2Solid Queue workers poll every 0.1 seconds and dispatchers every 1 second by default, using FOR UPDATE SKIP LOCKED where the database supports it.
  3. 3The Rails 8 authentication generator rate-limits sign-in to 10 attempts per 3 minutes and still leaves sign-up for you to build.
  4. 4Since Kamal 2.8, a basic deploy uses a local Docker registry by default, so Docker Hub or GHCR is optional.

Active Record

1. What is an N+1 query, and how do includes, preload and eager_load differ?

An N+1 query loads a collection with one query and then fires one more query per row when the code touches an association. Twenty posts that each call post.author.name in a view produce 21 queries.

  • preload always runs a separate query per association: one for posts, one for authors with WHERE id IN (...).
  • eager_load always uses a single LEFT OUTER JOIN, which is required when you filter or sort on the association's columns.
  • includes picks for you: separate queries by default, a join when the relation references the associated table through references or a hash condition on it.
# N+1: one query for posts, then one per author
Post.limit(20).each { |post| puts post.author.name }

# Two queries
Post.preload(:author).limit(20).each { |post| puts post.author.name }

# One JOIN query, needed because we filter on authors
Post.eager_load(:author).where(authors: { verified: true })

A strong candidate adds prevention, not only cures. strict_loading on a relation, a model or the whole app (config.active_record.strict_loading_by_default) raises or logs when code lazy loads an association, which catches N+1 queries in tests before they reach production.

A weak answer says "always use includes" and misses that eager loading a has_many with thousands of rows per parent trades many small queries for one huge allocation.

2. Find the bug: why does this job sometimes fail with RecordNotFound?

class Order < ApplicationRecord
  after_create :send_receipt

  private
    def send_receipt
      ReceiptJob.perform_later(self)
    end
end

Order.transaction do
  order = Order.create!(params)
  order.line_items.create!(items)
end

The callback enqueues the job inside the open transaction. A fast worker can pick it up before COMMIT, look the order up by its GlobalID and find nothing, because other connections cannot see uncommitted rows.

If the line items insert fails, the transaction rolls back and the job runs for an order that never existed.

The fix is to enqueue after the commit, with after_create_commit :send_receipt (or after_commit on: :create).

A strong candidate also mentions that Solid Queue stored in the same database as the app would make the enqueue part of the same transaction, and that the Solid Queue README warns against relying on that, because the guarantee disappears the day the queue moves to its own database, which is the Rails 8 production default.

3. How do you add an index or column to a large PostgreSQL table without downtime?

Build the index concurrently, outside the migration transaction, and add columns in steps that never rewrite or lock the table for long.

class AddIndexOnOrdersCustomerId < ActiveRecord::Migration[8.1]
  disable_ddl_transaction!

  def change
    add_index :orders, :customer_id, algorithm: :concurrently
  end
end

Points a senior candidate covers:

  • CREATE INDEX CONCURRENTLY cannot run inside a transaction, hence disable_ddl_transaction!. If it fails midway it leaves an invalid index that must be dropped before retrying.
  • Adding a column with a constant default is a metadata change on PostgreSQL 11 and later, but a volatile default or a backfill in the same migration still touches every row.
  • Backfill in batches with in_batches from a job or a separate script, then add NOT NULL through a validated check constraint.
  • Removing a column takes two deploys: first self.ignored_columns += ["legacy_flag"], then the migration, or running processes with a cached schema will error.
  • A lock_timeout stops a migration from queueing behind a long transaction and blocking every query behind it.

4. Why is a uniqueness validation not enough on its own?

validates :email, uniqueness: true runs a SELECT and then an INSERT, so two requests that arrive together both pass the check and both insert. Only a unique index in the database closes the race.

add_index :users, :email_address, unique: true

# Application code then handles the violation
def self.claim(email)
  create_or_find_by!(email_address: email)
end

Keep the validation for the friendly error message and the index for correctness. create_or_find_by tries the insert first and falls back to a lookup when the unique constraint raises ActiveRecord::RecordNotUnique, which is the safer order under concurrency than find_or_create_by.

The same reasoning applies to presence versus NOT NULL and to belongs_to versus a foreign key: a weak answer treats model validations as the data integrity layer, while a strong one treats them as UX on top of constraints.

5. What does this print, and what changed for enum declarations in Rails 8?

class Post < ApplicationRecord
  enum :status, { draft: 0, published: 1, archived: 2 }, default: :draft
end

post = Post.new
puts post.status
puts post.draft?
puts Post.published.to_sql

It prints draft, true, and a query with WHERE "posts"."status" = 1. The column stores the integer, the reader returns the string, and the enum defines predicates, bang setters such as post.published! and scopes for each value.

Rails 8.0 removed the old keyword-argument form, enum status: { ... }, so code copied from older tutorials now fails.

Candidates should also know to map values explicitly with a hash rather than an array, because inserting a new value in the middle of an array silently renumbers every later one and corrupts existing rows.

6. When do you use optimistic locking and when pessimistic locking?

Use optimistic locking when conflicts are rare and you can show the user an error, and pessimistic locking when two writers will collide often and the work is short.

  • Optimistic: add a lock_version integer column. Every update includes WHERE lock_version = n and raises ActiveRecord::StaleObjectError when another write got there first. No database lock is held between read and write, which suits forms that stay open for minutes.
  • Pessimistic: account.with_lock { ... } opens a transaction and runs SELECT ... FOR UPDATE, so concurrent writers wait. It suits balance updates, inventory decrements and counters.
account = Account.find(id)
account.with_lock do
  raise InsufficientFunds if account.balance < amount
  account.update!(balance: account.balance - amount)
end

A weak answer reads the balance, checks it in Ruby and calls update! without any lock.

A strong one also knows the cheapest option for simple counters: an atomic SQL update such as Account.where(id: id).update_counters(balance: -amount) or update_all with a guard condition, which needs no lock in Ruby at all.

7. What are deprecated associations in Rails 8.1, and when would you use them?

Rails 8.1 lets you mark an association with deprecated: true, and Active Record then reports every use of it, including indirect ones through preload, includes and nested attributes.

The Rails 8.1 announcement lists three modes: :warn (the default), :raise and :notify.

class Author < ApplicationRecord
  has_many :posts, deprecated: true
  has_many :articles
end

The use case is removing an association from a large codebase. Grep finds author.posts, but it misses includes(:posts) built from a variable, serializers that walk associations by name, and accepts_nested_attributes_for.

Running the test suite and production traffic in :warn or :notify mode for a release cycle, then switching tests to :raise, turns a risky deletion into a measured one.

8. How do Active Record encryption and normalizes work?

encrypts encrypts an attribute before it is written and decrypts it on read, with keys from Rails credentials. normalizes, added in Rails 7.1, transforms a value on assignment and when it is used in finder queries.

class User < ApplicationRecord
  encrypts :ssn
  encrypts :email_address, deterministic: true
  normalizes :email_address, with: ->(e) { e.strip.downcase }
end

User.find_by(email_address: " Ana@Example.COM ")  # matches "ana@example.com"

The tradeoff a candidate should state: non-deterministic encryption (the default) is stronger, but you cannot query by the column.

Deterministic encryption produces the same ciphertext for the same input, so find_by and unique indexes work, at the cost of revealing which rows share a value.

A strong answer also covers key rotation with previous keys and the fact that encrypted columns need more storage than the plaintext, so a string column limit can overflow.

Controllers, Routing and Security

9. What does params.expect fix compared with require and permit?

params.expect, added in Rails 8.0, declares the expected shape of the parameters and returns a 400 Bad Request when the input does not match.

With the older params.require(:user).permit(:name), a client that sends user=string instead of a hash triggers a NoMethodError and a 500, which pollutes error tracking and hides real bugs.

# Rails 8 scaffold style
def post_params
  params.expect(post: [ :title, :body, tag_ids: [] ])
end

# Array of hashes needs double brackets
params.expect(comments: [ [ :body, :author_id ] ])

Generated scaffolds in 8.1 use params.expect. A strong candidate explains mass assignment as the reason strong parameters exist at all: without them, a crafted user[admin]=true field would set any column.

A weak one permits params.permit! "for now" or passes params[:user] straight to update.

10. What does the Rails 8 authentication generator create, and what does it leave out?

bin/rails generate authentication creates User and Session models, a SessionsController, a PasswordsController with a PasswordsMailer for resets, and an Authentication concern included in ApplicationController.

The Rails 8 announcement is explicit that sign-up is left to you.

The concern is short enough to read in an interview. Its key method, from the 8.1 template:

def start_new_session_for(user)
  user.sessions.create!(user_agent: request.user_agent, ip_address: request.remote_ip).tap do |session|
    Current.session = session
    cookies.signed.permanent[:session_id] = { value: session.id, httponly: true, same_site: :lax }
  end
end

Details a candidate should notice:

  • Sessions live in a database table, so you can list and revoke them per device, which cookie-only sessions cannot do.
  • Every controller requires authentication by default; public actions opt out with allow_unauthenticated_access only: %i[ new create ].
  • User.authenticate_by takes the same time whether or not the email exists, which blunts timing-based account enumeration.
  • The password reset flow redirects with the same notice whether or not an account exists, and finds the user with User.find_by_password_reset_token!.

The generator leaves out sign-up, email confirmation, two-factor auth, OAuth and account lockout. A strong candidate can say which of those they would add for a B2B product and which gem or service they would reach for.

11. How does rate_limit work, and where does it fall short?

rate_limit, added in Rails 7.2, is a controller macro that counts requests per key inside a time window. The generated SessionsController uses it to cap sign-in attempts:

class SessionsController < ApplicationController
  allow_unauthenticated_access only: %i[ new create ]
  rate_limit to: 10, within: 3.minutes, only: :create,
    with: -> { redirect_to new_session_url, alert: "Try again later." }
end

By default the key is the client IP and the counters live in the configured cache store, so with Solid Cache they are rows in the cache database.

Limits a strong candidate names: behind a proxy, request.remote_ip is only correct if trusted proxies are configured; an attacker with many IPs bypasses a per-IP limit, so credential stuffing needs a per-account key (pass by: -> { params[:email_address] }) as well; and an app-level limit still spends a Puma thread per rejected request, so heavy abuse belongs at the proxy or CDN.

12. Find the bugs: what is wrong with this search action?

def index
  @users = User.where("name LIKE '%#{params[:q]}%'")
               .order(params[:sort])
end

# index.html.erb
<p>Results for <%= raw params[:q] %></p>

Three bugs:

  • SQL injection in where. String interpolation puts user input into SQL. Use a bound parameter and escape the wildcards: User.where("name LIKE ?", "%#{User.sanitize_sql_like(params[:q])}%").
  • SQL injection in order. Order clauses cannot be bound, so the only safe version maps input to an allowlist: order(SORTS.fetch(params[:sort], :created_at)).
  • XSS in the view. ERB escapes <%= %> output by default, and raw (like html_safe) turns that off. Remove it.

A weak candidate finds the first bug only. The Rails security guide covers all three, and a senior candidate will also check that sort values are not passed to send or public_send elsewhere in the codebase.

13. How does Rails protect against CSRF, and when do you turn it off?

protect_from_forgery in ActionController::Base checks an authenticity token on every non-GET request. Forms built with form_with embed the token, csrf_meta_tags exposes it to JavaScript, and Turbo sends it on its fetch requests.

A request without a valid token raises ActionController::InvalidAuthenticityToken under the default strategy.

You turn it off for endpoints that authenticate with something a browser does not attach automatically, such as a bearer token in an Authorization header, which is why ActionController::API skips it.

A weak answer disables it on a webhook or JSON endpoint that still authenticates with the session cookie, which reopens the attack.

A strong one adds that SameSite=Lax cookies, which the generator sets, block most cross-site POSTs but do not replace the token.

14. How do you design routes for nested resources?

Nest only one level deep and use shallow so member routes do not carry the parent ID they do not need.

resources :projects do
  resources :tasks, shallow: true
end
# /projects/:project_id/tasks      (index, create)
# /tasks/:id                       (show, update, destroy)

A strong candidate adds custom actions as new resources rather than verbs: resource :archive, only: %i[ create destroy ] under tasks instead of post :archive, which keeps controllers to the seven REST actions.

They should also know that the old catch-all get ":controller(/:action(/:id))" route, deprecated since Rails 5.0, now raises an ArgumentError on Rails main, per the October 2, 2026 This Week in Rails.

15. How does Russian doll caching work, and what breaks it?

Fragments nest inside each other, and each fragment's cache key includes its record's cache_key_with_version, which is built from updated_at.

Changing a record changes its key, so its fragment misses and is rebuilt, while unchanged inner fragments are reused.

<% cache @project do %>
  <h1><%= @project.name %></h1>
  <%= render partial: "tasks/task", collection: @project.tasks, cached: true %>
<% end %>

class Task < ApplicationRecord
  belongs_to :project, touch: true
end

Without touch: true, editing a task leaves the outer project fragment stale, which is the bug interviewers like to plant.

Other breakers: rendering per-user data (a "your task" badge) inside a shared fragment, and updating rows with update_all, which skips callbacks and timestamps. Template changes are handled by the template digest in the key.

In Rails 8 the default production store is Solid Cache, so the question extends naturally into question 20.

Jobs and the Solid Stack

16. How is Solid Queue built, and how does it avoid workers grabbing the same job?

Solid Queue stores jobs in database tables and runs four kinds of processes, per the Solid Queue README:

  • Workers claim jobs from the solid_queue_ready_executions table and run them, polling every 0.1 seconds by default.
  • Dispatchers move scheduled jobs to ready when they are due, every 1 second by default, and do concurrency maintenance.
  • The scheduler enqueues recurring tasks from config/recurring.yml.
  • The supervisor forks the others, tracks their heartbeats and restarts them.

Workers claim rows with SELECT ... FOR UPDATE SKIP LOCKED, so two workers polling at once skip each other's locked rows instead of waiting or double-processing.

The README recommends PostgreSQL 9.5+, MySQL 8+ or MariaDB 10.6+ for high throughput.

A strong candidate explains why jobs live in several tables (ready, scheduled, claimed, blocked, failed): workers poll a small hot table, not a table holding every job ever run.

17. Should Solid Queue run inside Puma or as its own process?

Both work. The generated config/puma.rb includes plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"], which starts the supervisor inside the web server, and bin/jobs runs it as a separate process.

The design tradeoff:

  • In Puma suits a single small server: one container, one deploy, no extra process to monitor. Jobs compete with web requests for CPU and database connections, and a memory-heavy job can slow page loads.
  • Separate process (a job role in Kamal's deploy.yml) lets you scale workers and web independently and restart one without the other.

Either way, the database connection pool has to cover worker threads plus web threads. A weak answer sizes pool for Puma alone and then sees ActiveRecord::ConnectionTimeoutError under load.

18. How do you stop two jobs for the same account from running at once?

Use Solid Queue's limits_concurrency, which blocks extra jobs that share a key until a slot frees up.

class SyncAccountJob < ApplicationJob
  limits_concurrency to: 1, key: ->(account) { account }, duration: 15.minutes

  def perform(account)
    account.sync_with_billing!
  end
end

Per the README, key is required, to defaults to 1, duration defaults to 3 minutes, group shares a limit across job classes, and on_conflict is :block by default or :discard.

The duration is a failsafe: if a worker dies holding the slot, the lock expires after that window.

A strong candidate sets it longer than the job's worst-case runtime and still makes the job safe to run twice, because the limit is a semaphore, not a guarantee against every overlap.

19. Find the bug: why does this job charge some customers twice?

class ChargeInvoiceJob < ApplicationJob
  retry_on Net::ReadTimeout, wait: :polynomially_longer, attempts: 5

  def perform(invoice)
    charge = PaymentGateway.charge(invoice.customer_token, invoice.total_cents)
    invoice.update!(paid_at: Time.current, charge_id: charge.id)
  end
end

A read timeout does not mean the charge failed. The gateway may have processed it and the response got lost, so retry_on charges again. The same happens if the process dies between the charge and update!.

The fix is idempotency: pass an idempotency key derived from the invoice (for example "invoice-#{invoice.id}") to the gateway, return early if invoice.paid_at is set, and record the attempt before calling out.

A strong candidate states the rule plainly: Active Job and Solid Queue deliver at least once, so every job that touches money or sends email must be safe to run twice.

They also know GlobalID serializes invoice as a reference and reloads it on perform, and that a deleted record raises ActiveJob::DeserializationError, which you handle with discard_on.

20. When would you keep Redis instead of using Solid Cache and Solid Cable?

Solid Cache stores cache entries on disk in a database table rather than in RAM, and the Rails 8 announcement describes it as supporting encryption and an explicit retention limit.

Solid Cable replaces Redis as the Action Cable pub/sub backend with fast polling and, by default, keeps messages for one day.

The tradeoff a senior candidate lays out:

  • For the Solid adapters: one fewer service to run and pay for, a cache much larger than RAM would allow, and backups and failover the team already has for the database.
  • For Redis: lower read latency on hot keys, sub-millisecond pub/sub for chat-style apps with many messages per second, and data structures (sorted sets, atomic counters) that the app may use directly.

A strong answer adds that the Solid adapters should sit in their own databases (the Rails 8 default config/database.yml defines separate cache, queue and cable databases in production) so cache churn does not bloat the primary database's write-ahead log or backups.

21. What are Active Job Continuations?

Rails 8.1 added ActiveJob::Continuable, which splits a job into steps and records progress so a restarted job resumes from the last completed step instead of from the start.

That matters on Kamal deploys, where containers stop and long jobs get interrupted.

class ProcessImportJob < ApplicationJob
  include ActiveJob::Continuable

  def perform(import_id)
    @import = Import.find(import_id)

    step :initialize do
      @import.initialize
    end

    step :process do |step|
      @import.records.find_each(start: step.cursor) do |record|
        record.process
        step.advance! from: record.id
      end
    end

    step :finalize
  end
end

A strong candidate explains that the cursor makes the process step resumable mid-loop, that code outside steps reruns on every resume (so the find at the top must be cheap and side-effect free), and that each record's processing still needs to be idempotent, because the job can stop after record.process and before advance!.

Hotwire and Views

22. What are the differences between Turbo Drive, Turbo Frames and Turbo Streams?

  • Turbo Drive intercepts link clicks and form submissions, fetches the next page and swaps the <body>, so full page loads behave like a single-page app without writing JavaScript.
  • Turbo Frames scope navigation to a <turbo-frame id="...">: a link inside the frame replaces only the matching frame from the response. Use them for inline edit forms, tabs and lazy-loaded panels with src and loading="lazy".
  • Turbo Streams deliver actions such as append, replace, remove and refresh that change any element by ID, either in a form response (format.turbo_stream) or over WebSockets from broadcasts_to.

A strong candidate picks the smallest tool for the job: Drive for most navigation, a frame when one region should update, streams when one action has to change several unrelated parts of the page or when other users need to see the change.

23. Find the bug: why does the form show nothing after a failed validation?

def create
  @post = Post.new(post_params)
  if @post.save
    redirect_to @post
  else
    render :new
  end
end

Turbo Drive expects a form submission to answer with a redirect or with a 4xx or 5xx status. A failed save that renders with the default 200 status is ignored, so the user sees no errors.

The fix is render :new, status: :unprocessable_content (HTTP 422).

The 8.1 scaffold template writes the status through ActionDispatch::Constants::UNPROCESSABLE_CONTENT, which resolves to :unprocessable_content on Rack 3.1 and later and to the older :unprocessable_entity name before that.

A candidate who has shipped Hotwire will name the 422 rule without prompting; one who has not will start debugging JavaScript.

24. What do Turbo 8 page refreshes with morphing change?

Turbo 8 can refresh the current page by fetching it again and morphing the DOM to match, keeping scroll position and element state, instead of replacing the body. You turn it on in the layout and pair it with model broadcasts:

<%# app/views/layouts/application.html.erb %>
<%= turbo_refreshes_with method: :morph, scroll: :preserve %>

class Task < ApplicationRecord
  broadcasts_refreshes
end

The page refreshes handbook describes the model: the server tells clients "this changed, refresh", and each client re-renders the page with its own permissions and data. That removes most hand-written stream templates.

The cost a strong candidate names: every refresh re-renders the whole page on the server for every connected client, so a busy page with heavy queries needs caching, and elements that must survive a morph (a video, an open menu) need data-turbo-permanent.

25. When does a Rails team choose Stimulus, and when React?

Stimulus attaches small controllers to server-rendered HTML through data-controller, data-action and data-*-target attributes.

It fits toggles, clipboard buttons, form behavior and wrappers around third-party widgets, and new Rails 8 apps load it through importmap without a JavaScript build step.

React (or a similar framework) earns its build pipeline when the UI holds a lot of client-side state: a canvas editor, a spreadsheet grid, offline support. A strong candidate does not frame this as a religious choice.

They can describe mounting a React island inside one page of a Hotwire app, and they know jsbundling-rails or vite_ruby replace importmap when the app needs a bundler.

A weak answer picks a single-page app by default and then rebuilds routing, auth and forms that Rails already provides.

Deployment, Testing and Performance

26. How does a Rails 8 app deploy with Kamal 2?

Kamal builds a Docker image from the app's generated Dockerfile, pushes it to a registry, pulls it on each server over SSH and switches traffic with kamal-proxy, which handles zero-downtime deploys and Let's Encrypt certificates.

Inside the container, Thruster sits in front of Puma for asset caching, compression and X-Sendfile.

  • kamal setup installs Docker on fresh servers and boots the proxy and app; kamal deploy ships later versions.
  • Kamal 2.8 (October 19, 2025) made a local registry the default for simple deploys; the Rails 8.1 announcement still recommends a remote registry for larger setups.
  • Secrets go in .kamal/secrets, and since Rails 8.1 they can come from encrypted credentials: KAMAL_REGISTRY_PASSWORD=$(rails credentials:fetch kamal.registry_password).
  • Roles in config/deploy.yml split web and job servers; accessories run databases or other services on the same hosts.

A strong candidate knows what Kamal does not do: it has no autoscaling and no managed database, so backups, monitoring and OS patching remain the team's job. That is the real cost behind "no PaaS required".

27. How do credentials and the master key work?

bin/rails credentials:edit opens config/credentials.yml.enc, an encrypted YAML file committed to git, and the key that decrypts it lives in config/master.key or the RAILS_MASTER_KEY environment variable, which is never committed.

Per-environment files such as config/credentials/production.yml.enc with their own keys let staff edit staging secrets without production access.

Code reads values with Rails.application.credentials.dig(:stripe, :secret_key). Wrapping required secrets in fetch at boot raises on a missing key, which is better than a nil surfacing hours later in a payment call.

A weak answer commits master.key or copies secrets into .env files on laptops.

A strong one has rotated a leaked key: generate a new one, re-encrypt, redeploy, and revoke the old upstream secrets, because the old encrypted file is still in git history.

28. How do you structure tests for a Rails app, and what is bin/ci?

Rails ships with Minitest, fixtures and parallel testing.

A balanced suite keeps most tests at the model and request level (ActionDispatch::IntegrationTest), where they are fast and stable, and uses a small number of system tests with Capybara for flows that need a real browser and JavaScript.

Rails 8.1 added a local CI runner: steps declared in config/ci.rb run through bin/ci.

CI.run do
  step "Style: Ruby", "bin/rubocop"
  step "Security: Brakeman", "bin/brakeman --quiet --no-pager"
  step "Tests: Rails", "bin/rails test"

  if success?
    step "Signoff", "gh signoff"
  else
    failure "Signoff", "Fix the issues and try again."
  end
end

The optional signoff step needs the GitHub CLI and the basecamp/gh-signoff extension.

A strong candidate can argue both sides: running CI on a fast developer machine is quicker and cheaper than a hosted runner, but it trusts the developer's environment, so teams still keep a hosted pipeline for anything a branch protection rule depends on.

They should also know that each test runs inside a transaction that rolls back, so a test that depends on run order or on data left by another test will flake once parallel testing splits the suite across workers.

29. How do you tune a Rails app for throughput?

Start from measurements, then work through the stack in this order:

  • Queries: fix N+1 queries, add missing indexes, and move work out of the request into jobs.
  • Puma: processes for CPU parallelism (Ruby threads share one interpreter lock per process), threads for I/O waits. Rails defaults to 3 threads per process.
  • Connection pool: at least the Puma thread count per process, plus any in-process job threads.
  • YJIT: the 8.1 defaults set config.yjit to !Rails.env.local?, so YJIT is on in production and off in development and test.
  • Caching: fragment and low-level Rails.cache.fetch caching once the queries are clean.

A strong candidate knows that Ruby 4.0 ships ZJIT as YJIT's planned successor and that the Ruby 4.0 release notes advise against using ZJIT in production yet.

A weak answer jumps to "rewrite the slow endpoint in Go" before reading a single query plan.

30. How does Rails handle multiple databases and read replicas?

Each database gets an entry in config/database.yml, and an abstract model class connects to it with connects_to. Read replicas use roles:

class ApplicationRecord < ActiveRecord::Base
  primary_abstract_class
  connects_to database: { writing: :primary, reading: :primary_replica }
end

ActiveRecord::Base.connected_to(role: :reading) do
  Report.monthly_totals
end

Automatic role switching sends GET and HEAD requests to the replica unless the session wrote recently, which protects users from reading their own write before it replicates.

The Solid adapters use the same mechanism: Solid Queue reads its database from config.solid_queue.connects_to.

A strong candidate brings up replication lag, the fact that a migration on the primary must finish replicating before code that reads the new column hits the replica, and that horizontal sharding (connects_to shards:) needs the shard key on every query.

What Changed Recently

Oct 19, 2025
Kamal 2.8 pushes and pulls images through a local registry by default
Oct 22, 2025
Rails 8.1: Active Job Continuations, Rails.event, bin/ci, deprecated associations
Dec 25, 2025
Ruby 4.0 ships ZJIT, experimental Ruby Box and the Ractor::Port API
Mar 24, 2026
Rails 8.1.3 fixes inflection and JSON encoding bugs and raises the minimum PostgreSQL to 9.5
Jun 18, 2026
Kamal 2.12 adds OpenTelemetry deploy logs and --lock-wait
Jul 29, 2026
Rails 8.1.3.1 disables libvips untrusted loaders in Active Storage; libvips 8.13 minimum
Oct 2, 2026
Rails main raises the minimum Ruby to 3.3.5 and removes dynamic controller routes
Nov 4, 2026
Rails 8.1.4.1 and 8.0.5.2 security releases; 8.0 security support ends Nov 7

31. What did Rails 8.1 add, beyond continuations and deprecated associations?

The Rails 8.1 release on October 22, 2025 added several features a candidate who upgraded should be able to name:

  • Structured event reporting: Rails.event.notify("user.signup", user_id: 123) emits structured events, Rails.event.tagged and Rails.event.set_context attach tags and context, and subscribers implement #emit(event) to send them to a log pipeline.
  • Markdown responses: format.md { render markdown: @page }, with the model supplying to_markdown.
  • Local CI with config/ci.rb and bin/ci (question 28).
  • Kamal secrets from credentials with rails credentials:fetch (question 26).

The 8.1 release notes also list changes that show up in code review: columns in schema.rb are now sorted alphabetically, which produces a large one-time diff; the built-in sidekiq adapter is deprecated in favor of the one in the sidekiq gem; and update_all with WITH or DISTINCT is deprecated.

32. What in Ruby 4.0 can break or help a Rails app?

Ruby 4.0 shipped on December 25, 2025. Rails 8.1 requires Ruby 3.2.0 or newer, so 3.4 and 4.0 both run it. The changes most likely to surface in an upgrade:

  • Set is a core class and Set#inspect now prints Set[1, 2, 3], which breaks tests that compare inspected output. SortedSet is gone from the standard library.
  • CGI was removed from the default gems except cgi/escape, so old code that requires cgi for anything else fails at boot.
  • Net::HTTP no longer sets Content-Type: application/x-www-form-urlencoded on requests with a body, which can break hand-rolled API clients.
  • Ractor replaced Ractor.yield and Ractor#take with Ractor::Port; few Rails apps use Ractors, but gems that did need updates.
  • ZJIT is available with --zjit, not yet recommended for production.

The 3.4 and 4.0 lines both still get patches: Ruby 4.0.9 and 3.4.12 shipped on October 23, 2026 with Onigmo regular expression fixes.

A strong candidate runs the suite on the new Ruby in CI before switching production, and checks native gems for compatibility first.

33. How do you plan Rails upgrades around the maintenance policy?

Rails releases a feature version about every six months, gives each minor series one year of bug fixes and two years of security fixes, and extends the previous series if a year passes without a release.

The current dates from the maintenance page: 8.0 security support ended November 7, 2026, and 8.1 gets security fixes until October 10, 2027.

The process a senior candidate describes: upgrade one minor version at a time, fix deprecation warnings on the current version first (set config.active_support.deprecation = :raise in test), run bin/rails app:update, keep config.load_defaults on the old version and adopt new defaults one at a time through new_framework_defaults_8_1.rb, and run the dual-boot Gemfile pattern in CI if the jump is large.

They should also expect the next release to need Ruby 3.3.5 or newer, since Rails main raised its minimum in October 2026.

Signs of a Strong Answer

  • They name the SQL a line of Active Record will run, and count the queries a view triggers before suggesting a fix.
  • They back every model validation that guards integrity with a database constraint or index.
  • They treat every job as at-least-once and can say how each one behaves if it runs twice.
  • They enqueue jobs and send emails from after_commit, never from inside an open transaction.
  • They can argue for and against Solid Cache and Solid Cable with latency and operations costs, not preference.
  • They know which Rails and Ruby versions are in production, when security support ends, and what the next upgrade will break.

Hiring Ruby on Rails Developers

Rails developers who have run zero-downtime migrations on large tables, moved jobs off Redis and upgraded an app through two major versions are hard to find through job boards.

Second Talent helps US startups hire vetted AI-Native Engineers from Asia, including Ruby on Rails developers and full stack developers, screened with questions like these.

For the data layer underneath most Rails apps, see our PostgreSQL and Redis interview guides.

Rates run $23 to $39 USD an hour, billed monthly, with matches in 24 hours and a 90-day one-time replacement guarantee. Compare rates on the cost to hire a backend developer page, or tell us what you need.

Get developers who ship with AI agents.

Starts at $25/Hour.

Start Hiring

$0 cost until you hire