Extend AR to handle legacy fieldname casing

Hello all,

I’m hoping one of you has already done this, or just has the
metaprogramming-fu that I don’t.

I want to extend ActiveRecord::Base#method_missing to try matching the
columns with downcase if the case-sensitive match fails.

For instance, fieldname ‘LotsaLuck’ fails if accessed with
Mymodel.lotsaluck
NoMethodError: undefined method `lotsaluck’ for #Mymodel:0x58160dc

I think maybe the alternative is a way to switch on downcasing in the
connection_adapter when it gets the columns collection ?

Thanks for any help you may have!

Peter F.


Apple MacBook. Black. It’s the new White!