How do you check in Rails3 (with or without Arel) if a date is filled in (as in, not null)? I know you can do it by using:
obj.where('PLANNED IS NOT NULL')
but is it possible without using SQL?
// SQL
SELECT * FROM projecttasks WHERE planned IS not null
I tried:
# all tasks which have a date
tasks = Projecttask.where(:planned => !nil)
or
# all task with no planned date (sql: is null)
Projecttask.where(:planned => nil)
But that doesn’t work. In general, how you can do a ‘where’ on NULL and NON NULL columns.
Thanks.
You can check this similar question for the answer. The answer by Ryan Bigg is what I’m guessing you are looking for.
Rails where condition using NOT NULL