Hi! I'm Avdi Grimm, and this is my software development blog. More...
Books and Screencasts
Small plates of gourmet Ruby code.
Watch me build an app from scratch.
Objects on Rails
A developer notebook on applying classic Object-Oriented principles to Ruby on Rails projects.
The definitive guide to exceptions and failure handling in Ruby.
Category Archives: Rails
Today’s free Monday episode features a rare delving into Rails code. We take a look at a fat controller, and thin it down by identifying the model lifecycle events that are hiding inside it. This episode garnered a lot of … Continue reading
How I avoid finding myself in database bizarro world while testing Rails apps. Continue reading
How to add helper methods to all associations of a given type, as well as to the model class. Continue reading
Avoiding silent truncation of your model fields requires putting length validations on them. But this can introduce duplication of knowledge. In this post I demonstrate how to pull limit information directly from the DB into your model validations. Continue reading
It occurred to me recently that my experience as a Rails developer may be somewhat unique. I often get brought in to help preexisting Ruby/Rails projects evolve and mature in a sustainable way. As a result, the vast majority of … Continue reading
Designing HTML views is an iterative, interactive process by nature. And anything that slows down the iterations, slows down development. I was working on a form recently where the steps to show it went something like this: Go to the … Continue reading
decent_exposure helps you program to an interface, rather than an implementation in your Rails controllers. Sharing state via instance variables in controllers promotes close coupling with views. decent_exposure gives you a declarative manner of exposing an interface to the state … Continue reading
Sometimes I like to number rows using a counter when rendering lists of things: <% @products.each_with_index do |product, i| %> <li class=”product_<%= i %>”><%= product.name %></li> <% end %> They are handy for testing, among other things. Of course, if … Continue reading
It’s an oft-stated fact that most disasters result not from a single point of failure but from a combination of failures reinforcing each other. I wouldn’t term the problem I ran into last Friday a disaster, but it certainly cost … Continue reading