How can I use ActiveRecord on a database that has a column named ‘valid’? (DangerousAttributeError)

Try this:

class MyTable < AR:Base
   class << self
     def instance_method_already_implemented?(method_name)
       return true if method_name == 'valid'
       super
     end
   end
end

It’s a hack, and it might not work in rails 3, but it could fix the problem for now.

I found it on the ruby on rails mailing list

If you wanted, you could also look at datamapper, which handles these sort of things somewhat more sanely.

Leave a Comment