Ruby on Rails
Overview
Ruby on Rails is a web application framework that includes everything needed to build database-backed apps using the Model-View-Controller pattern. It favors convention over configuration, with Active Record for persistence plus libraries for mail, jobs, WebSockets, file storage, and rich text. Read this when scaffolding, routing, modeling data, or organizing a Rails app.
Official sources
Install / setup
# Install the Rails gem (Ruby must already be installed)
gem install rails
# Create a new application
rails new store
Core concepts
- Convention over configuration: predictable file locations and naming reduce boilerplate; following conventions is what makes Rails productive.
- MVC layers: Models (domain/data, usually Active Record), Views (templates, typically HTML with embedded Ruby), Controllers (handle HTTP requests and coordinate responses).
- Active Record: maps classes to tables and provides associations, validations, and query methods; migrations evolve the schema.
- Routing:
config/routes.rb maps URLs to controller actions, with RESTful resource routing as the default idiom.
- Generators:
rails generate scaffolds models, controllers, and migrations following conventions.
- Asset and frontend pipeline: Rails integrates view templates and bundled JS/CSS for full-stack rendering.
Best practices
- Lean on RESTful resource routes and conventional naming so generators and helpers work as intended (https://guides.rubyonrails.org/getting_started.html).
- Use migrations for every schema change so databases stay reproducible across environments.
- Keep business logic in models/service objects rather than controllers (fat-model/skinny-controller idiom).
- Use the built-in test framework (Minitest) and fixtures to cover models and controllers.
Common pitfalls
- Fighting conventions (custom paths, non-standard names) → generators, autoloading, and helpers break; follow Rails naming.
- Putting heavy logic in controllers or views → move it into models or plain Ruby objects for testability.
- Editing the schema by hand instead of via migrations → environments drift; always generate and run migrations.
Examples
# config/routes.rb
Rails.application.routes.draw do
resources :articles
root "articles#index"
end
Further reading
Related skills
- ../laravel — analogous convention-driven full-stack framework in PHP
- ../phoenix — MVC-style framework with realtime, in Elixir
1---2name: rails3description: Convention-driven full-stack Ruby MVC framework with Active Record; consult when building or maintaining a Ruby on Rails backend.4domain: stack5category: backend6tags: [ruby, rails, mvc, active-record, web-framework]7official_sources:8 - https://guides.rubyonrails.org/9 - https://github.com/rails/rails10verified: 2026-06-1611metadata:12 source: https://skillmd.com/skills/gabriel7silva/rails13---1415# Ruby on Rails1617## Overview18Ruby on Rails is a web application framework that includes everything needed to build database-backed apps using the Model-View-Controller pattern. It favors convention over configuration, with Active Record for persistence plus libraries for mail, jobs, WebSockets, file storage, and rich text. Read this when scaffolding, routing, modeling data, or organizing a Rails app.1920## Official sources21- Docs: https://guides.rubyonrails.org/22- Repo: https://github.com/rails/rails23- Install / download: https://guides.rubyonrails.org/getting_started.html (install Ruby/Rails: https://guides.rubyonrails.org/install_ruby_on_rails.html)2425## Install / setup26```bash27# Install the Rails gem (Ruby must already be installed)28gem install rails2930# Create a new application31rails new store32```3334## Core concepts35- Convention over configuration: predictable file locations and naming reduce boilerplate; following conventions is what makes Rails productive.36- MVC layers: Models (domain/data, usually Active Record), Views (templates, typically HTML with embedded Ruby), Controllers (handle HTTP requests and coordinate responses).37- Active Record: maps classes to tables and provides associations, validations, and query methods; migrations evolve the schema.38- Routing: `config/routes.rb` maps URLs to controller actions, with RESTful resource routing as the default idiom.39- Generators: `rails generate` scaffolds models, controllers, and migrations following conventions.40- Asset and frontend pipeline: Rails integrates view templates and bundled JS/CSS for full-stack rendering.4142## Best practices43- Lean on RESTful resource routes and conventional naming so generators and helpers work as intended (https://guides.rubyonrails.org/getting_started.html).44- Use migrations for every schema change so databases stay reproducible across environments.45- Keep business logic in models/service objects rather than controllers (fat-model/skinny-controller idiom).46- Use the built-in test framework (Minitest) and fixtures to cover models and controllers.4748## Common pitfalls49- Fighting conventions (custom paths, non-standard names) → generators, autoloading, and helpers break; follow Rails naming.50- Putting heavy logic in controllers or views → move it into models or plain Ruby objects for testability.51- Editing the schema by hand instead of via migrations → environments drift; always generate and run migrations.5253## Examples54```ruby55# config/routes.rb56Rails.application.routes.draw do57 resources :articles58 root "articles#index"59end60```6162## Further reading63- https://guides.rubyonrails.org/getting_started.html — Getting started64- https://guides.rubyonrails.org/active_record_basics.html — Active Record basics65- https://guides.rubyonrails.org/routing.html — Rails routing6667## Related skills68- ../laravel — analogous convention-driven full-stack framework in PHP69- ../phoenix — MVC-style framework with realtime, in Elixir