Custom Boolean Definition

Greetings.

I have a legacy database that cannot be changed. The true/false values in the database are true = -1, false = 0 (Thank you very much VB...) Unfortunately, when I interact with these, rails/ruby sees everything as false, which causes all sorts of havoc.

Is there a way to define (in my model or elsewhere) true as -1 instead of 1?

or

Is there a way to access the true/false field as an integer so I can manually test for true/false by

if customer.some_field == -1 then...

Thanks for your help. The lifeline of my project / job depend on making this work.

You could do something evil like this:

  class MyModel < ActiveRecord::Base     def stupid_value       read_attribute(:stupid_value) * -1     end

    def stupid_value=(val)       write_attribute(:stupid_value, (val * -1))     end   end

It's not a great solution, but it should work.

--Jeremy