Free through lesson 3

Ruby & Ruby on Rails for Beginners

From Ruby syntax to Rails MVC, Active Record, forms and authentication, testing with RSpec, Hotwire, and deploying with Docker and Kamal. In 50 lessons, you'll get to the point where you can build and launch a members-only blog with login. All code, command output, and test results were actually run on Ruby 3.4.10 and Rails 8.1.3.1.

about 2 hours in total (estimate)

Slides for this course (for classes and in-house training) →

Curriculum

The 50 lessons are split into 7 chapters. We recommend going in order from chapter 1, but feel free to jump to whatever interests you. * Ruby and Rails can't run in the browser, so try things with the Ruby 3.4 you install in lesson 2 and the Rails 8.1 app you create in lesson 9.

Chapter 1 — Ruby Syntax (lessons 1–8)

Before getting into Rails, you'll learn to write Ruby itself. You'll cover variables and methods, arrays and hashes, blocks, classes and modules, and exceptions, running everything with the ruby command as you go.

1

What Is Ruby? (Everything Is an Object)

A first look at Ruby, the foundation of Rails. Learn two quirks: even numbers have methods, and the last evaluated expression is the return value.

about 2 min Free preview Free
2

Setting Up (rbenv, gem, Bundler)

Pin the Ruby version per project. The difference between gem and Bundler, what Gemfile and Gemfile.lock do, and why you use bundle exec.

about 3 min Free
3

Variables and Methods (Passing Arguments)

Local variables, instance variables, and constants. Default arguments, keyword arguments, variable-length arguments, and the convention for method names ending in ? and !.

about 2 min Free
4

Conditionals and Loops (unless and each)

How to write if, unless, and case/in, and why you loop with each or times instead of for. Plus modifier if and guard clauses for exiting early.

about 2 min 🔒 Basic
5

Arrays and Hashes

Creating arrays and getting values out, symbol keys in hashes, and digging into nested data. Plus how Rails params is a hash.

about 3 min 🔒 Basic
6

Blocks and Enumerable (map, select, reduce)

Dig into blocks, the reason Rails code is so short. When to use do…end vs { }, how map differs from each, and what &:name really is.

about 3 min 🔒 Basic
7

Classes and Modules (Inheritance and Mixins)

attr_accessor, initialize, inheritance, and super. Plus how mixins, which include a module to blend in features, are exactly what Rails concerns are.

about 3 min 🔒 Basic
8

Exceptions and Gems (rescue and Bundler)

How to write begin/rescue/ensure and raise. Why you define your own exception classes, and the steps from adding a gem to the Gemfile to running bundle install.

about 4 min 🔒 Basic

Chapter 2 — Getting Rails Running (lessons 9–15)

You'll create an app with rails new and follow how the three pieces, routing, controllers, and views, connect. By the end of this chapter, you'll be able to add a URL and show your own page.

Chapter 3 — Active Record (lessons 16–23)

You'll create tables with migrations and read and write them through models. You'll work through validations, associations, and scopes, and finish by spotting N+1 queries in the logs and fixing them.

16

Migrations and the Schema

Create tables in Ruby instead of SQL. The files rails generate model creates, db:migrate and db:rollback, and why schema.rb is the source of truth.

about 3 min 🔒 Basic
17

Models and CRUD (Create, Read, Update, Delete)

The difference between new and create, what save returns, update and destroy. Use db/seeds.rb to get back to the same state as often as you like.

about 3 min 🔒 Basic
18

Writing Queries (where, order, limit)

Building search conditions, and the fact that Active Record is lazy. Check the SQL with to_sql, and cut wasteful loading with pluck and exists?.

about 3 min 🔒 Basic
19

Validations

Check values before saving. presence, length, uniqueness, numericality, and how to read errors. What's happening when save returns false.

about 2 min 🔒 Basic
20

Associations (belongs_to and has_many)

Connect foreign keys and model associations. Categories and posts, posts and comments. What gets left behind if you forget dependent.

about 3 min 🔒 Basic
21

Many-to-Many (has_many through)

Represent relationships where "both sides are many," like posts and tags, with a join table. How to write through, and reassigning with <<.

about 2 min 🔒 Basic
22

Scopes and Callbacks

Name common conditions with scope, why to avoid default_scope, and hooking into saving with before_save and after_create.

about 3 min 🔒 Basic
23

N+1 Queries and Indexes

Measure the two main reasons list pages get slow. Count the SQL queries in the log and reduce them with includes and indexes.

about 3 min 🔒 Basic

Chapter 4 — Forms and Authentication (lessons 24–31)

You'll accept input with form_with and use Strong Parameters to limit which fields are accepted. You'll write authentication by hand with has_secure_password, then replace it with Devise, and finish by making sure users can edit only their own posts.

24

Forms (form_with)

Build a page that accepts input. Create seven URLs with resources, see the HTML and CSRF token form_with generates, and send users back to the form on errors.

about 3 min 🔒 Basic
25

Strong Parameters

Why you must not pass params straight through. What require and permit mean, permitting nested values and arrays, and the error you get if you forget.

about 3 min 🔒 Basic
26

Completing CRUD

Write all seven actions. Consolidate record loading with before_action, and add edit, update, destroy, and a delete confirmation.

about 3 min 🔒 Basic
27

Flash Messages and Redirects (PRG)

Why you redirect after saving, notice and alert, the difference between flash and flash.now, and the pattern that prevents double submission.

about 2 min 🔒 Basic
28

Writing Authentication by Hand (has_secure_password)

Build your own system that never stores passwords in plain text. bcrypt, authenticate, and what to put in the session.

about 3 min 🔒 Basic
29

Adding Authentication with Devise

Switch to the go-to gem. The config devise:install generates, choosing modules, the eight routes it adds, and current_user.

about 3 min 🔒 Basic
30

Authorization (Requiring Login and Checking Ownership)

Authentication vs authorization. Require login with before_action, and let users edit only their own posts. Why you must not accept user_id from params.

about 2 min 🔒 Basic
31

[Practice] Managing Posts per User

Tie everything so far together. Run through login, creating posts, commenting, and owner-only editing to confirm it all works.

about 2 min 🔒 Basic

Chapter 5 — Testing and Quality (lessons 32–38)

So you notice right away when something breaks, you'll run both Minitest and RSpec. You'll create test data with FactoryBot, check whole pages with request specs, and let RuboCop and Brakeman review your style and security holes for you.

Chapter 6 — Real-World Features (lessons 39–45)

You'll use Hotwire to update parts of the page with almost no JavaScript, and Active Job to push heavy work into the background. You'll also cover file uploads, email, and translating your app into Japanese: the things that always come up in real work.

Chapter 7 — Build and Launch (lessons 46–50)

With credentials and environment variables, asset precompilation, and Docker and Kamal, you'll get your app into a shape you can launch. Finally, you'll compare it side by side with Laravel and get a map of where to go next.

Once you finish all 50 lessons, move on to Database Fundamentals with PostgreSQL to learn indexes and query plans in depth, PHP & Laravel Intro Course to see the same kind of full-stack framework in another language, or Intro to Shipping and Running a Service to learn how to run things after launch. A membership unlocks every course.