Everyone uses Ruby on Rails. That's the problem.
Rails is an incredible framework that revolutionized web development. But somewhere along the way, "Ruby web development" became synonymous with "Rails," and that's done a disservice to both newcomers and the Ruby ecosystem itself.
This book argues for a different path: Sinatra.
Rails gives you 50,000 lines of framework code before you write a single line of your own. It's "convention over configuration" until you need to configure something, at which point you're Googling for hours trying to understand the magic happening behind the scenes.
Sinatra is 158 lines of code. You can read the entire source in an afternoon and actually understand what's happening.
Rails teaches you Rails. Sinatra teaches you web development.
When you learn Sinatra, you learn:
- How HTTP actually works
- What routes really are
- How request/response cycles function
- Why REST matters
- What middleware does
Rails abstracts all of this away. That's great when you're experienced. It's terrible when you're learning.
Need an API? A webhook receiver? A simple web service? A microservice? Rails is bringing a freight train to a bicycle race.
Sinatra boots in milliseconds, has minimal dependencies, and doesn't make assumptions about your database, your ORM, your asset pipeline, your JavaScript framework, or your preferred brand of coffee.
Even if you end up using Rails (and you might!), understanding Sinatra will make you a better Rails developer. You'll understand what Rails is doing under the hood, when to fight the framework, and when to embrace it.
This book takes you from zero to production-ready web applications using nothing but Sinatra and your wits.
-
Why Not Rails? A manifesto for the unconvinced
-
Hello World: Your First Sinatra App From
gem installto running server in 5 minutes -
Routes, Requests, and Responses Understanding HTTP without the magic
-
Views and Templates Making things pretty with ERB, HAML, and friends
-
Working with Data Databases, ORMs, and when not to use either
-
Forms and User Input Handling data without Rails form helpers
-
Sessions, Cookies, and Authentication Keeping users logged in without Devise
-
Building a RESTful API JSON, status codes, and API design
-
Testing Sinatra Applications RSpec, Rack::Test, and why tests matter
-
Deployment and Production Getting your app into the real world
- Beginners who want to learn web development without drowning in framework magic
- Rails developers who want to understand what's happening under the hood
- API developers who don't need the full Rails stack
- Anyone who's tired of 10-second boot times
- Basic Ruby knowledge (variables, methods, classes)
- A computer with Ruby installed
- A text editor
- Curiosity about how the web actually works
This book has three core principles:
- Understand, don't memorize: We'll explain why things work, not just how
- Simple beats complex: If we can solve it with 10 lines instead of 100, we will
- Real-world ready: Every example could be (and in some cases, is) production code
Web development is serious business. This book occasionally isn't. If you find a joke that doesn't land, just git blame it and send me a pull request with something funnier.
Ready to learn web development the Sinatra way?
Start with Chapter 1: Why Not Rails?
This book is a work in progress. Found a bug? Have a suggestion? The code is cleaner than the prose? Open an issue or submit a PR.
MIT License - Because knowledge should be free, and also because I can't afford a lawyer to write a custom license.
Remember: Rails developers are just Sinatra developers who got comfortable.
Let's keep you uncomfortable for a little while longer.