small medium large xlarge

Advanced Rails Recipes: 84 New Ways to Build Stunning Rails Apps


Cover image for Advanced Rails Recipes

Advanced Rails Recipes

84 New Ways to Build Stunning Rails Apps


With the help of a community of Rails chefs in the kitchen, here are 84 new ways to kick your Rails apps up a notch. Advanced Rails Recipes is a collection of practical recipes for spicing up your web application without a lot of prep and cleanup. You’ll learn how the pros have solved the tough problems using the most up-to-date Rails 2 techniques so you can deliver your stunning web app quicker and easier.

Customer Reviews

I can’t recommend it enough. And if you’re looking for new ways to use Capistrano, you’ll find Mike’s book stocked with (at last count) 9 great deployment- and capistrano-related tips, including how to create custom maintenance pages, running multistage deployments, preserving files between deployments, responding to remote prompts, and more. You won’t be disappointed.

- Jamis Buck

Author of Capistrano

From a quick look through the beta PDF, this will surely be one of the most useful Rails books for an advanced hacker ever written.

- Jarkko Laine

Not only does it show you how to do things, it also explains why and when you should use them. …
Major kudos to the author, Mike Clark, for making such an awesome book. Even though it’s still in beta, I really recommend this book to anyone who wants to expand their Rails knowledge

- Dennis Martinez

Hard to put in words all the knowledge you will gain while reading this book. It goes beyond your standard recipe book since it spends lots of time telling you why you are doing things
not just how to do them. From high level architecture to elegant template recipes, this book covers all the bases. A must have for anyone who wants to bring their Rails knowledge to a new level.

- Kent Fenwick


See All Reviews

About this Title

Pages: 464
Published: 2008-05-01
Release: P1.0 (2008-05-01)
ISBN: 978-0-9787-3922-5

Ruby on Rails continues to build up a tremendous head of steam. Fueled by significant benefits and an impressive portfolio of real-world applications already in production, Rails is destined to continue making significant inroads in coming years.

Each new Rails application showing up on the web adds yet more to the collective wisdom of the Rails development community. Yesterday’s best practices yield to today’s latest and greatest techniques, as the state of the art is continually refined in kitchens all across the Internet. Indeed, these are times of great progress.

At the same time, it’s easy to get left behind in the wake of progress. Advanced Rails Recipes keeps you on the cutting edge of Rails development and, more importantly, continues to turn this fast-paced framework to your advantage.

Advanced Rails Recipes is filled with pragmatic recipes you’ll use on every Rails project. And by taking the code in these recipes and slipping it into your application you’ll not only deliver your application quicker, you’ll do so with the confidence that it’s done right.

The book includes contributions from Aaron Batalion, Adam Keys, Adam Wiggins, Andre Lewis, Andrew Kappen, Benjamin
Curtis, Ben Smith, Chris Bernard, Chris Haupt, Chris Wanstrath, Cody Fauser,
Dan Benjamin, Dan Manges, Daniel Fischer, David Bock, David Chelimsky, David
Heinemeier Hansson, Erik Hatcher, Ezra Zygmuntowicz, Geoffrey Grosenbach,
Giles Bowkett, Greg Hansen, Gregg Pollack, Hemant Kumar, Hugh Bien, Jamie
Orchard-Hays, Jamis Buck, Jared Haworth, Jarkko Laine, Jason LaPier, Jay
Fields, John Dewey, Jonathan Dahl, Josep Blanquer, Josh Stephenson, Josh
Susser, Kevin Clark, Luke Francl, Mark Bates, Marty Haught, Matthew Bass,
Michael Slater, Mike Clark, Mike Hagedorn, Mike Mangino, Mike Naberezny, Mike Subelsky,
Nathaniel Talbott, PJ Hyett, Patrick Reagan, Peter Marklund, Pierre-Alexandre
Meyer, Rick Olson, Ryan Bates, Scott Barron, Tony Primerano, Val Aleksenko,
and Warren Konkel.

Contents & Extracts

(hyperlinks point to extracts)

  • REST and Routes Recipes
    • Create A RESTful Resource
    • Add Your Own RESTful Actions
    • Nest Resources to Scope Access
    • Toggle Attributes with AJAX
    • Authenticate REST Clients
    • Respond To Custom Formats
    • Catch All 404s
  • Database Recipes
    • Add Foreign Key Constraints
    • Write Custom Validations
    • Take Advantage of Master/Slave Databases
    • Siphon Off SQL Queries
    • Use Fixtures For Canned Datasets
  • User Interface Recipes
  • Search Recipes
    • Improve SEO with Dynamic Meta Tags
    • Build a Sitemap
    • Quick & Dirty Search
    • Full-Text Search with Ferret
    • Full-Text Search with Sphinx
    • Solr-Power Your Search
  • Design Recipes
    • Freshen Up Your Models With Scope
    • Create Meaningful Relationships Through Proxies
    • Keep Forms DRY and Flexible
    • Prevent Train Wrecks
    • Simplify Controllers With a Presenter
  • Integration Recipes
    • Process Credit Card Payments
    • Play Nice with Facebook
    • Mark Locations On a Google Map
    • Tunnel Back to Your Application
  • Console Snacks
    • Writin’ Console Methods
    • Console Loggin’
    • Playin’ In the Sandbox
    • Accessin’ Helpers
    • Shortcuttin’ the Console
  • Asynchronous Processing Recipes
    • Send Lightweight Messages
    • Off-Load Long-Running Tasks to BackgrounDRb
    • Process Asynchronous, State-Based Workflows
  • E-mail Recipes
    • Validate E-mail Addresses
    • Receive E-mail Reliably via POP or IMAP
    • Send E-mail Via Gmail
    • Keep E-mail Addresses Up To Date
  • Testing Recipes
    • Maintain Fixtures Without Frustration
    • Describe Behavior from the Outside-In With RSpec
    • Test First with Shoulda
    • Write Domain-Specific RSpec Matchers
    • Write Custom Testing Tasks
    • Test JavaScript With Selenium
    • Mock Models with FlexMock
    • Track Test Coverage with RCov
    • Automatically Validate HTML
    • Mock With a Safety Net
    • Drive a Feature Top-Down with Integration Tests
  • Performance and Scalability Recipes
    • Cache Data Easily
    • Look Up Constant Data Efficiently
    • Profile In The Browser
    • Cache Up With the Big Guys
    • Dynamically Update Cached Pages
    • Use DTrace for Profiling
  • Security Recipes
    • Constrain Access to Sensitive Data
    • Encrypt Sensitive Data
    • Flip On SSL
  • Deployment and Capistrano Recipes
    • Upload Custom Maintenance Pages
    • Generate Custom Error (404 and 500) Pages
    • Config Files On-The-Fly
    • Create New Environments
    • Run Multi-Stage Deployments
    • Safeguard the Launch Codes
    • Automate Periodic Tasks
    • Preserve Files Between Deployments
    • Segregate Page Cache Storage with Nginx
    • Load Balance Around Your Mongrels’ Health
    • Respond To Remote Capistrano Prompts
    • Monitor (and Repair) Processes with Monit
  • Big-Picture Recipes
    • Manage Plugin Versions
    • Fail Early
    • Give Users Their Own Subdomain
    • Customize and Analyze Log Files


Mike Clark is an independent consultant, author, trainer, and programmer. He’s the co-author of Agile Web Development with Rails, author of Pragmatic Project Automation, and runs The Pragmatic Studio. He helped build one of the first commercial Rails applications and continues working on other Rails projects (including this very bookstore!) through his company, Clarkware Consulting.