Leslie Viljoen:
> I am processing database rows and I see that there are "bit" columns
> that come out of ActiveRecord as true or false. I wanted binary digits
> so I did this:
> 
> class FalseClass
>   def to_i
>     0
>   end
> end
> 
> class TrueClass
>   def to_i
>     1
>   end
> end
> 
> .which may or may not be really dumb. So is it really dumb?

It isn't really dumb, but you can get into problems when debugging code
independent of your ActiveRecord. The issue is basically that you place the
solution of a problem of your record into another class, where it does not
belong. I'd suggest something like (untested)

class MyRecord
  def my_column_as_int
    my_column? ? 1 : 0
  end
end

or even (untested as well)

class MyRecord

  alias my_column_as_bool my_column 
  def my_column
    my_column_as_bool ? 1 : 0
  end

  alias my_column_as_bool= my_column=
  def my_column=(val)
    val = false if val == 0
    self.my_column_as_bool = val
  end

end

Kalman