Preface

Everyone cool seems to agree: Ruby on Rails is an amazing way to build web (or heck, Web 2.0) applications. Ruby is a powerful and flexible programming language, and Rails takes advantage of that flexibility to build a web application framework that takes care of a tremendous amount of work for the developer. Everything sounds great!

Except, well… all the Ruby on Rails books talk about this “Model-View-Controller” thing, and they start deep inside the application, close to the database, most of the time. From an experienced Rails developer’s perspective, this makes sense—the framework’s power lies largely in making it easy for developers to create a data model quickly, layer controller logic on top of that, and then, once all the hard work is done, put a thin layer of interface view on the very top. It’s good programming style, and it makes for more robust applications. Advanced Ajax functionality seems to come almost for free!

From the point of view of someone learning Ruby on Rails, however, that race to show off Rails’ power can be extremely painful. There’s a lot of seemingly magical behavior in Rails that works wonderfully—until one of the incantations isn’t quite right and figuring out what happened means unraveling all that work Rails did. Rails certainly makes it easier to work with databases and objects without spending forever thinking about them, but there are a lot of things to figure out before that ease becomes obvious.

If you’d rather learn Ruby on Rails more slowly, starting from pieces that are more familiar to the average web developer and then moving slowly into controllers and models, you’re in the right place. You can start from the HTML you already likely know, and then move more deeply into Rails’ many interlinked components.

Note

This updated version of Learning Rails covers version 2.x up through version 2.3.5, but will mention places where Rails 3.0 will be different. The Rails 3.0 beta arrived recently, and while we can’t encourage learning Rails on beta software, being ready for the future is important too.

Who This Book Is For

You’ve probably been working with the Web for long enough to know that writing web applications always seems more complicated than it should be. There are lots of parts to manage, along with lots of people to manage, and hopefully lots of visitors to please. Ruby on Rails has intrigued you as one possible solution to that situation.

You may be a designer who’s moving toward application development or a developer who combines some design skills with some programming skills. You may be a programmer who’s familiar with HTML but who lacks the sense of grace needed to create beautiful design—that’s a fair description of one of the authors of this book, anyway. Wherever you’re from, whatever you do, you know the Web well and would like to learn how Rails can make your life easier.

The only mandatory technical prerequisite for reading this book is direct familiarity with HTML and a general sense of how programming works. You’ll be inserting Ruby code into that HTML as a first step toward writing Ruby code directly, so understanding HTML is a key foundation. (If you don’t know Ruby at all, you probably want to look over Appendix A or at least keep it handy for reference.)

Cascading Style Sheets (CSS) will help you make that HTML look a lot nicer, but it’s not necessary for this book. Similarly, a sense of how JavaScript works may help. Experience with other templating languages (like PHP, ASP, and ASP.NET) can also help, but it isn’t required.

You also need to be willing to work from the command line sometimes. The commands aren’t terribly complicated, but they aren’t (yet) completely hidden behind a graphical interface. Even Heroku Garden, an online integrated development environment (IDE) for Rails, still has some necessary command-line features.

Get Learning Rails: Live Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.