Rails "Good Touch"/"Bad Touch"

Ryan Sonnek bio photo By Ryan Sonnek

Rails is bit like a dirty old man.

Consider this example

class User   
  after_save :do_something_expensive
end

Rails makes it trivial to update timestamps, and I found out the hard way that the underlying implementation leaves a lot to be desired.

User.first.touch

Easy, right? But, did you know that this useful little method will fire all of your after_save callbacks?  This led to some nasty performance problems recently, and now you can now stop Rails from having it’s way with you!  Bad Touch Rails!

The good_touch project is now available on github and gemcutter and eliminates the overhead for updating a simple timestamp attribute.  It’s as easy as using the standard/bad touch method without all the horseplay.

User.first.good_touch

Let the touching continue…