sqlite boolean 't' and 'f' with rails active record
In sqlite3, boolean value is not supported. So rails use char 't' and 'f' to represent boolean value true and false. while in other database like mysql, postgresql, the real boolean value true and false is used.
However, this difference is transparent to rails Model. you can just use
FollowUp.where(is_compete: true)
to filter completed followups and
FollowUp.where(is_compete: false)
to get incomplete followups
Using sqlite3 in Rails 4.2.5, I find that a boolean field returns ruby true or false when queried from Rails console. However, when queried inside a controller method, it returns a "t" or "f" string. Very weird. So I added a model method:
def fixt? return self[:fixt] == "t"end
Schema:
t.boolean "fixt", default: false