Finding by subclass of string in activerecord fails under certain situations

Ran in to a problem where we were running to to a lot of these errors when we upgraded to Rails 3.0.3:

NoMethodError: undefined method `visit_Foo’ for #Arel::Visitors::MySQL:0x104d0f4d0

After some digging, it turned out that arel used the to lookup the visitor for obj. In our app, Foo is a subclass of String that we use for tracking URL and domain normalization logic. Using it in activerecord #create works, but finders mostly don’t work. See the Lighthouse case for info:

I added a patch to #to_s String values before sending them off to arel. Feedback on the patch is greatly appreciated.


Jeff Pollard