I want to have @messages return @folder.messages where the value of column \"deleted\" is NOT equal to true. I\'m not sure why this keeps throwing a SQLException. I guess
@ms = @msgs.where("deleted != ?", true)
# OR
@ms = @msgs.where(:deleted => false)
true
is different for different databases. In some it is t/f
value, and in some true/false
, so you should or place it in quotes and be sure if it is right for your particular database, or you should exclude it out of your sql so Rails will do the job for you.
UPD
If deleted
is NULL
. First. Set deleted field as a false by default. Second, how to find it with AR:
@ms = @msgs.where("deleted = ? OR deleted = ?", false, nil)
# wich won't work, Thanks to @mu is too short
@ms = @msgs.where("deleted = ? OR deleted IS NULL", false)