Start reading Rails AntiPatterns: Best Practice Ruby on Rails Refactoring on the free Kindle Reading App or on your Kindle in under a minute. Don't have a Kindle? Get your Kindle here.

Deliver to your Kindle or other device

Enter a promotion code
or gift card

Try it free

Sample the beginning of this book for free

Deliver to your Kindle or other device

Sorry, this item is not available in
Image not available for
Image not available

Rails AntiPatterns: Best Practice Ruby on Rails Refactoring (Addison-Wesley Professional Ruby Series) [Kindle Edition]

Chad Pytel , Tammer Saleh
4.7 out of 5 stars  See all reviews (13 customer reviews)

Digital List Price: $35.99 What's this?
Print List Price: $44.99
Kindle Price: $19.79
You Save: $25.20 (56%)

Free Kindle Reading App Anybody can read Kindle books—even without a Kindle device—with the FREE Kindle app for smartphones, tablets and computers.

To get the free app, enter your email address or mobile phone number.


Amazon Price New from Used from
Kindle Edition $19.79  
Paperback $35.99  
Shop the New Digital Design Bookstore
Check out the Digital Design Bookstore, a new hub for photographers, art directors, illustrators, web developers, and other creative individuals to find highly rated and highly relevant career resources. Shop books on web development and graphic design, or check out blog posts by authors and thought-leaders in the design industry. Shop now

Book Description

The Complete Guide to Avoiding and Fixing Common Rails 3 Code and Design Problems

As developers worldwide have adopted the powerful Ruby on Rails web framework, many have fallen victim to common mistakes that reduce code quality, performance, reliability, stability, scalability, and maintainability. Rails™ AntiPatterns identifies these widespread Rails code and design problems, explains why they’re bad and why they happen—and shows exactly what to do instead.

The book is organized into concise, modular chapters—each outlines a single common AntiPattern and offers detailed, cookbook-style code solutions that were previously difficult or impossible to find. Leading Rails developers Chad Pytel and Tammer Saleh also offer specific guidance for refactoring existing bad code or design to reflect sound object-oriented principles and established Rails best practices. With their help, developers, architects, and testers can dramatically improve new and existing applications, avoid future problems, and establish superior Rails coding standards throughout their organizations.

This book will help you understand, avoid, and solve problems with

  • Model layer code, from general object-oriented programming violations to complex SQL and excessive redundancy
  • Domain modeling, including schema and database issues such as normalization and serialization
  • View layer tools and conventions
  • Controller-layer code, including RESTful code
  • Service-related APIs, including timeouts, exceptions, backgrounding, and response codes
  • Third-party code, including plug-ins and gems
  • Testing, from test suites to test-driven development processes
  • Scaling and deployment
  • Database issues, including migrations and validations
  • System design for “graceful degradation” in the real world

Editorial Reviews

About the Author

Chad Pytel is the founder and CEO of thoughtbot, a software development firm specializing in Ruby on Rails, and creators of Paperclip, Shoulda, FactoryGirl, and Hoptoad, among other projects. thoughtbot embraces both agile development methodologies and a “getting real” project philosophy. Chad coauthored Pro Active Record: Databases with Ruby and Rails (Apress, 2007) and has presented at various conferences around the world. To follow along with Chad and the rest of the thoughtbot team’s ideas on development, design, technology, and business, visit their blog at

Tammer Saleh
is the director of engineering at Engine Yard. He wrote the Shoulda testing framework, was the primary developer and project manager for thoughtbot’s fantastic Hoptoad service, and is an experienced Ruby on Rails trainer and speaker. In previous lives, he’s done AI development for the NCSA and the University of Illinois, as well as systems administration for both and Caltech’s Earthquake Detection Network. You can find him online at

Product Details

  • File Size: 7464 KB
  • Print Length: 400 pages
  • Simultaneous Device Usage: Up to 5 simultaneous devices, per publisher limits
  • Publisher: Addison-Wesley Professional; 1 edition (November 9, 2010)
  • Sold by: Amazon Digital Services, Inc.
  • Language: English
  • ASIN: B004C04QE0
  • Text-to-Speech: Enabled
  • X-Ray:
  • Word Wise: Not Enabled
  • Lending: Not Enabled
  • Amazon Best Sellers Rank: #127,045 Paid in Kindle Store (See Top 100 Paid in Kindle Store)
  •  Would you like to give feedback on images?

Customer Reviews

4.7 out of 5 stars
4.7 out of 5 stars
Share your thoughts with other customers
Most Helpful Customer Reviews
23 of 23 people found the following review helpful
5.0 out of 5 stars Finally, a Rails book worth reading!!! March 17, 2011
Format:Paperback|Verified Purchase
I'll be honest, prior to reading this book I was starting to lose faith in Ruby on Rails authors. As a beginner to Rails, I've read a number of books to try and make sense of all the black magic going on behind the scenes as well as how to write great code in Rails. Many of those books were either "paint by number" tutorials where you didn't really learn anything appreciable or very complete (and hard to comprehend) reference manuals for everything there is to possibly know about Rails.

I just needed a good in between book! This book not only exposes you to the Rails Way of writing code in Ruby on Rails, it also gives many of the opposing examples which I would more than likely stumble down not knowing any better.

Not only that, but this is one of the most logically organized books I have ever had the pleasure to read. Everything flows together very nicely and is very understandable for beginners let alone more advanced users.

I would recommend this book in a heart beat (and I already have... many, many times). Great job guys! I really appreciate the effort you put into writing this book! You have restored my faith in Rails authors!
Was this review helpful to you?
9 of 9 people found the following review helpful
5.0 out of 5 stars A more useful way to teach design patterns June 15, 2011
Format:Paperback|Verified Purchase
All too often, the 'patterns' books only develop a greenfield example the 'right' way. This is hopelessly optimistic, especially if (as is the case for me) you're teaching undergraduates how to use design patterns; they're not going to get it right the first time. So *refactoring* code that has "grown bad" to use a good pattern is a much more frequently needed skill.

There are other books on refactoring for Ruby, like Martin's, but i like that this one focuses on design patterns and specifically on how to leverage Ruby's features to realize the patterns nicely.

My future coverage of design patterns in Berkeley's undergraduate software engineering class will be motivated by the examples in this book.
Comment | 
Was this review helpful to you?
8 of 8 people found the following review helpful
5.0 out of 5 stars Fantastic source of refactoring ideas December 9, 2010
Format:Paperback|Verified Purchase
This book makes a great companion to Martin Fowler's Refactoring book (or the Ruby version of it by Jay Fields). As someone who's still accumulating the theoretical 10,000 hours of experience it takes to master something (Ruby/Rails), it's nice to have guides like Chad and Tammer there to suggest improvements to my technique. Highly recommended for anyone novice or intermediate Rails developer.
Comment | 
Was this review helpful to you?
3 of 3 people found the following review helpful
Format:Paperback|Verified Purchase
The ideal and essential book for intermediate level people learning rails. You've gone through the guide(s), maybe even micharl hartl's, or baserails (excellent, not so well known resource btw). Now, what? How do you build your own complex idea that have more than just has_many associations, or are clones of popular apps? What does fat model actually mean in practice? How do I loosely couple and APPLY law of demeter?

This book is not just about what not to do, or refractoring things to that it's extra "rails-y". The reason it's so valuable for intermediate developers is because by seeing the recommended ways to implement, and organize your code, against anti-patterns (aka bad practices that don't fully utilize what rails designed to make neat and concise), you get to LEARN the rails methods and features that don't even show up in all of the beginner rails tutorials in out there, and you get to learn exactly how to USE methods and features that rails has to offer without going into ultra low level ruby that leave you scratching your head, and frustrated.

Just like how object oriented design philosophy tells you to use interfaces to not care about the detailed implementation of distant objects, so too should teaching something relatively complicated and confusing like a framework teach you how and what to use its methods and features without bogging you down with every single detail about the method, or approaching it from such a highly academic, and non-practical way. This book does just that.
Read more ›
Comment | 
Was this review helpful to you?
2 of 2 people found the following review helpful
5.0 out of 5 stars Lots of value for an experienced Rails developer, too February 3, 2011
While the book certainly seems geared toward the novice/intermediate Rails developer, I still loved it even after building Rails apps for several years. The advice was divided for me among three categories - stuff that I already know and do on a regular basis, stuff that I know but *don't* do as often as I should, and practices that were new to me. Admittedly, there isn't a ton of info in the book that falls into the latter category, but it is in there, and it's stuff you won't find in any other book. It would be worth reading even for just those nuggets.

What took me by surprise, though, was how much of the book reinforced concepts I was already partially familiar with but haven't been disciplined enough to practice regularly, and practices that I follow regularly but didn't fully grasp why. This book lays it all out, and with real world examples. Everything I read in the book I can apply to the projects I work on everyday. Whether you're new to Rails or an old hat, this book *will* help you write better Rails applications. Read it, think about it, and apply it.
Comment | 
Was this review helpful to you?
Most Recent Customer Reviews
5.0 out of 5 stars A must read for Rails programmers
A must read for Rails programmers. Very applicable, made me want to refactor a lot of my code and made me a better programmer.
Published 4 months ago by Robert Daniels
5.0 out of 5 stars Great to read through from beginning to end
Works great as a resource to thumb through when you need to. I read it from beginning to end and just ate up every chapter. Read more
Published 14 months ago by Ben Johnston
5.0 out of 5 stars Immensely helpful guide to writing more maintainable Rails apps.
I'm currently teaching myself Rails development largely via Ryan Bates' RailsCasts and endless StackOverflow comments. Read more
Published 15 months ago by Aja B.
5.0 out of 5 stars I Love It!
This book each rails dev should read more than once, it so well written and examples are really good. Read more
Published 23 months ago by Milan Jaric
4.0 out of 5 stars Good book
Learned some points. Though some other points are obvious for experienced rails developers. It would be more useful for new rails developers.
Published on December 31, 2012 by YI ZHANG
3.0 out of 5 stars Quite useful if you are just starting
I am not a ROR expert by any stretch (I have been coding on it for about 10 months) however I was able to digest this book in about 2 hours and this few months back. Read more
Published on August 25, 2011 by Matteo Melani
5.0 out of 5 stars Stay on Track with Rails AntiPatterns
This book rules. There are so many good suggestions and I would say almost every Rails developer has encountered these messy situations before and scratched their head wondering... Read more
Published on May 31, 2011 by anorakcity
4.0 out of 5 stars Good practical advice
Every section of every chapter of this book provides practical refactoring advice, and for every section I've found myself putting the book down in order to dig into my current... Read more
Published on January 3, 2011 by Amazon Customer
Search Customer Reviews

More About the Authors

Discover books, learn about writers, read author blogs, and more.


There are no discussions about this product yet.
Be the first to discuss this product with the community.
Start a new discussion
First post:
Prompts for sign-in

Look for Similar Items by Category