Skip to content
IT glossary
BackendUpdated December 3, 2026

Ruby on Rails

Ruby on Rails is a web framework for the Ruby programming language. It provides built-in tools for handling requests, working with a database, and returning HTML pages or API responses.

Also known as: Rails, Ruby

What Rails is

Ruby is a programming language; Rails is a framework written in Ruby. Rails gives a web application a standard project layout and components that already work together. You can use it to serve complete HTML pages or to build a JSON API for a mobile app or a separate frontend.

How a request moves through Rails

The router matches an HTTP method and path to a controller action. For example, GET /books/42 can call BooksController#show with 42 available as params[:id]. The action reads the input, coordinates any work needed to handle the request, and chooses a response. For an HTML page, that usually means rendering a view template. A JSON endpoint can return data without an HTML view.

This division of responsibilities is known as Model–View–Controller (MVC). Rails commonly uses Active Record, its object–relational mapper, for models backed by a relational database. Active Record maps a class such as Book to a table called books by default. That's convention over configuration: when you follow the naming rules, you don't need to write that mapping yourself. You can override the convention when working with a schema that uses different names.

Example: a read-only endpoint

# config/routes.rb (inside Rails.application.routes.draw)
resources :books, only: [:show]

# app/controllers/books_controller.rb
class BooksController < ApplicationController
  def show
    book = Book.find(params[:id])
    render json: { id: book.id, title: book.title }
  end
end

Assuming a Book model and a books table exist, find looks up the row by primary key. If it exists, the client gets 200 OK and a JSON object with the book's ID and title. If it doesn't, find raises ActiveRecord::RecordNotFound, which Rails maps to 404 Not Found by default.

Where it fits and what to watch for

Rails is useful for storefronts, admin tools, and SaaS applications that do a lot of creating, reading, updating, and deleting records. Database migrations record schema changes in code, and Active Job gives apps a common interface for work that can run outside the request, such as sending a receipt email.

Using an ORM doesn't remove the need to understand SQL. Say a page lists books and displays each book's author. Fetching the books and then calling book.author for every row can produce one query for the list and one more per book. That's the N+1 problem. If every row needs its author, try Book.includes(:author) and inspect the SQL log to check that the extra per-book queries are gone.

What interviewers ask

Expect to trace a request from the route to the response, explain where a database query happens, or diagnose an N+1 from a log. Another common question is whether a model validation can guarantee uniqueness. It can provide useful feedback, but two concurrent requests can both pass the check before either writes. A unique index enforces the rule at the database level.