Introduction vi
Whenever a code listing is large and significant, and I suspect that you might want to use it verbatim in your
own code, I supply a listing heading. There are not too many of those. The whole set of code listings will not
add up to a complete working system, nor are there 30 pages of sample application code in an appendix. The
code listings should serve as inspiration for your production-ready work, but keep in mind that it often lacks
touches necessary in real-world work. For example, examples of controller code are often missing pagination
and access control logic, because it would detract from the point being expressed.
Some of the source code for my examples can be found at http://github.com/obie/tr3w_time_and_expenses.
Note that it is not a working nor complete application. It just made sense at times to keep the code in the
context of an application and hopefully you might draw some inspiration from browsing it.
Concerning 3rd-Party RubyGems and Plugins
Whenever you find yourself writing code that feels like plumbing, by which I mean completely unrelated to
the business domain of your application, you’re probably doing too much work. I hope that you have this
book at your side when you encounter that feeling. There is almost always some new part of the Rails API or
a third-party RubyGem for doing exactly what you are trying to do.
As a matter of fact, part of what sets this book apart is that I never hesitate in calling out the availability of
third-party code, and I even document the RubyGems and plugins that I feel are most crucial for effective
Rails work. In cases where 3rd-party code is better than the built-in Rails functionality, we don’t cover the
built-in Rails functionality (pagination is a good example).
An average developer might see his productivity double with Rails, but I’ve seen serious Rails developers
achieve gains that are much, much higher. That’s because we follow the Don’t Repeat Yourself (DRY) principle
religiously, of which Don’t Reinvent The Wheel (DRTW) is a close corollary. Reimplementing something
when an existing implementation is good enough is an unnecessary waste of time that nevertheless can be
very tempting, since it’s such a joy to program in Ruby.
Ruby on Rails is actually a vast ecosystem of core code, official plugins, and third-party plugins. That
ecosystem has been exploding rapidly and provides all the raw technology you need to build even the most
complicated enterprise-class web applications. My goal is to equip you with enough knowledge that you’ll be
able to avoid continuously reinventing the wheel.
Recommended Reading and Resources
Readers may find it useful to read this book while referring to some of the excellent reference titles listed in
this section.
Most Ruby programmers always have their copy of the “Pickaxe” book nearby, Programming Ruby (ISBN:
0-9745140-5-5), because it is a good language reference. Readers interested in really understanding all of the
nuances of Ruby programming should acquire The Ruby Way, Second Edition (ISBN: 0-6723288-4-4).
I highly recommend Peepcode Screencasts, in-depth video presentations on a variety of Rails subjects by the
inimitable Geoffrey Grosenbach, available at http://peepcode.com
Ryan Bates does an excellent job explaining nuances of Rails development in his long-running series of free
webcasts available at http://railscasts.com/