Fix for "random" NoMethodError in Rails' ActiveRecord

July 09, 2009

I’m a little excited today because some code I wrote was accepted into the Ruby on Rails core.

It’s a patch I wrote to fix a tricky bug I ran into in ActiveRecord which can cause a call to one of your model’s attribute methods to sometimes throw a NoMethodError.

I came across this bug after upgrading a site I help maintain to Rails 2.3. This site allows users to download demos of software. Users have to specify which operating system they want a demo for, and this is stored in a database column named system.