Books to learn programming with Ruby and Rails

A List of Books to Learn Programming with Ruby and Rails

This post provides a curated list of books to learn to code in Ruby and build web applications with Rails. It also gives a step-by-step path you can follow to learn enough before moving to the next step. If you ever wanted to learn to program but didn't know where to start, this post is for you.

8 min read

Ever since I started writing about Ruby and Rails on this blog, I’ve received dozens of emails and messages from students, programmers, and non-software professionals on how to get into programming and start learning Ruby on Rails to build web applications.

After replying to a lot of these queries both in person and online on various forums and emails, I decided to save some keystrokes and compile everything into a blog post that I could point to and keep updated.

What follows is a curated collection of books to learn to program in Ruby and build web applications using Rails. Each section provides a path that you can follow to learn enough before moving to the next section.

This post only covers books. Could you learn by watching YouTube, screencasts, or online courses? Probably, but reading books is how I learned Ruby and Rails, and it's the best way I know how to learn anything. So books it is. If you know other material, please mention them in a comment below.

Now, if you haven't programmed before, you might have two questions:

Why Ruby? The simple answer is: it's easy and it's fun. That's it. If you were turned off from programming because you learned Java, C, or C++ in college and found them too complicated, try Ruby. It's different. Most programming languages are designed to make the compiler happy. Ruby is designed to make developers happy.

Why Rails? It makes it very easy to build web applications. Many of the popular web applications that you know and love (Shopify, Airbnb, Zendesk, Github, HEY, and thousands more) are using Ruby on Rails. Even the initial version of Twitter was built with Rails. Finally, if you want to program Ruby professionally, you'll need to learn Rails.

Before you feel intimidated by this list of books to read, remember that learning to program is a long-term journey and it's good to set clear expectations.

What You Should Know Before Starting Your Programming Journey

Here're a few things to keep in mind before you jump in, if you've never programmed before but want to start.

Your age doesn’t matter. You can start learning to program at any age and become quite good at it in a relatively short time if you apply yourself and take it seriously. Don't let anyone tell you that you're either too young or too old to code.

Your background doesn’t matter. No matter what work you were doing before, you can (and will) learn how to program if you practice diligently.

You'll have to spend some money, but it won’t be thousands and thousands of dollars on university degrees, coding bootcamps, or online programs. Just be willing to purchase a few good books. And I mean purchase, do not use the free PDF copies you find online. Trust me, the effort you invest in your learning resources impacts how you learn.

The psychological concept of effort justification states that people tend to attribute a higher value to an outcome if they've put effort into it.

You don’t need to study programming for eight hours a day. In fact, you shouldn’t. That’s a road to burnout. If you have a busy schedule, studying in full concentration for 90 minutes every day is more than enough, even better than doing nothing for a week and a marathon 8-hour session on Sunday.

No matter what anyone tells you, Ruby is the best programming language to start your programming journey. Don’t think that Ruby is some niche language used by passionate hobbyists. Some of the biggest companies you know use Ruby.

There's a lot of bad advice out there about getting started in tech and people are trying to get into AI/Crypto and trying to build Web3 apps when they don't know what HTML is, just because some influencer on YouTube told them to. DON'T DO THAT!

For programmers only: If someone tells you "Ruby is slow", or "Rails doesn’t scale" run away from them as far as possible. Either they have no idea what they’re talking about, or they're pitching you a JavaScript framework that was created last month, or they work for a giant company like Google, Microsoft, or Facebook and want to promote the big and complicated framework or language they built for their use cases but won’t apply to you as a solo developer with limited resources.

Finally, don’t expect to start learning tomorrow and hope to become proficient and land a cushy, work-from-home tech job next month. This is a long-term process. Anyone who tells you otherwise is trying to sell you their book/course/bootcamp and get your money. However, if you stick to the path and practice every day, you’ll be amazed at how much progress you can make in just a few months.

With that out of the way, let's look at how you should proceed on your journey to become a web developer.

Learning Ruby

Books to Learn Ruby

Assuming you've never programmed before, I recommend starting with Chris Pine's excellent book Learn to Program. It's an awesome beginner-friendly book, and Chris explains each topic in programming in an easy-to-understand way. This book should get you started with Ruby pretty quickly, also teaching you the fundamental concepts in programming such as conditionals and loops.

Learning the basics of any programming language is one thing, you need to know the best practices in that language to write good software. For this, check out Russ Olsen's Eloquent Ruby, which is one of the best Ruby books I've read. I read it twice last year and can't recommend it enough. Even though it was published in 2011, most of the best practices mentioned in it remain unchanged.

At this point, you should be able to write simple Ruby programs. Now you can start the next section (learning to build web applications) in parallel while you learn intermediate Ruby.

Intermediate Ruby

After reading these two books, you should have a solid understanding of Ruby and you'd be able to read and write Ruby programs. At this point, you must be itching to go even deeper into Ruby and learn the various core classes and standard libraries included in Ruby.

To learn Ruby in depth, I recommend reading Programming Ruby by Dave Thomas. Also known as the Pick-Axe book, this is one of the oldest and most famous books in the Ruby community, and many well-respected Ruby & Rails programmers attribute their initiation to Ruby to this book. If you decide to read just one book from this list, this should be it.

Advanced Ruby

Finally, there's one book that I recommend to everyone to really master the Ruby language, which is Paolo Perrotta's Metaprogramming Ruby 2. This book not only teaches the powerful metaprogramming concepts in Ruby, but also how to use them judiciously.

Metaprogramming Ruby 2

The primary benefit of metaprogramming I found was not so much in writing clever code, but instead reading and understanding open source code, especially the Rails source code. For a preview, check out my notes.

Reference Books

I recommend using the following two books as references at hand instead of reading them end-to-end.

Reference Books for Ruby
  1. The Well-Grounded Rubyist is a good book that covers various features of Ruby in-depth, including metaprogramming.
  2. Hal Fulton's Ruby Way: The Solutions and Techniques in Ruby Programming is a wonderful book covering core classes and standard library in-depth.

Intermission: Learn Web Development with Sinatra

When you feel comfortable with Ruby, the obvious next step is to learn Rails. However, I'd ask you to be a little patient and try Sinatra, which is a lightweight web framework for Ruby.

I feel that too often, new developers make two mistakes on their path to becoming a Rails developer:

  1. Jumping into Rails without learning Ruby, or
  2. Starting to build Rails applications without having a basic understanding of how most web applications work.

Then they see everything that Rails does for you, and either feel it's all magic (it's not!) and get overwhelmed and ultimately discouraged and leave the journey altogether.

Don't do that!

Sinatra is very simple to get up and running in less than a minute. It's just a Ruby file.

# myapp.rb
require 'sinatra'

get '/' do
  'Hello world!'
end

Then you add a view, some HTML, CSS, and JavaScript, and you have a complete web application. Building one or two simple web applications (e.g. a blog or a to-do list) using Sinatra will give you a good taste of web development, and you'll be ready to tackle basic Rails concepts such as routing, views, etc.

This stage shouldn't take long. Your goal is not to master Sinatra or web development right now (it's a lifelong journey), but just to get familiar enough to not get scared when you see a Rails application.

While you're making your way through Sinatra, I strongly suggest you learn the basic concepts of HTML, CSS, and JavaScript at the same time. The best resource I know to learn front-end development is Free Code Camp. It's excellent. This should give you a good understanding of the fundamental building blocks of web applications.

Learning Ruby on Rails

Books to Learn Rails

After you've been programming in Ruby for a while, have a basic understanding of how web applications work, and have preferably built a few, you're ready to learn Ruby on Rails, the framework you'll use most likely as a professional Ruby developer.

To learn Rails, I recommend starting with The Agile Web Development with Rails book. Reading this book end-to-end and actually coding while you're reading will give you a great introduction to Rails.

Next, you should read Michael Hartl's Rails Tutorial. Again, read it end-to-end and build the project in the book as your read it. Reading these two books and live-coding Rails apps will give you the confidence to build web applications on your own.

At this point, you'll be curious to learn how Rails really works and more advanced features of it. To learn how Rails works, there's nothing better than reading the Rails source code.

For a deeper understanding of Rails, I recommend reading the latest edition of The Rails Way by Obie Fernandez. A warning: reading this book is a slog, as it's huge and covers almost all of Rails features in-depth. However, the trick is to read this book over multiple passes. Every time you read it, you'll learn a bunch of new things that you didn't get before. I'm currently on my third read of the book.

Finally, to understand how Rails works behind the scenes, read Noah Gibbs' book: Rebuilding Rails. It's an excellent book that shows you how you can build your own web development framework. After reading this book, a lot of Rails magic started making sense to me. Highly recommended.


That's a wrap. I hope you enjoyed reading this post and plan to start reading at least one book from the above list.

If you’ve read till the end, I’ve got something to ask you. Most of the people reading this blog are already experienced Rails developers, so you must be already aware of these books and know many points I mention above.

What I ask you is that you share this post with someone you know who wants to learn to code but doesn’t know where to start. Whether it’s your retired mom or dad, your teenage kid, or your friends in finance or marketing who want to switch careers. As I mentioned earlier, there's a lot of bad advice on getting started in programming, and I think they'll find it useful.

As always, if you have any questions or feedback, or would like to recommend more books, please leave a comment below or send me an email. I look forward to hearing from you.

If you'd like to receive future articles directly in your email, please subscribe to my blog. If you're already a subscriber, thank you.