views:

30

answers:

2
 Contract.all(:conditions => ['voided == ?', 0]).size
 => 364
 Contract.all(:conditions => ['voided != ?', 0]).size
 => 8
 Contract.all.size
 => 441

the 3 numbers does not added up (364 + 8 != 441). What's the proper way write the :conditions to count the rows which the voided column value is NULL or equal to zero?

+1  A: 
Contract.all(:conditions => {:voided => nil})

or

Contract.all(:conditions => ['voided IS NULL'])
Eimantas
A: 
 Contract.all(:conditions => ["voided is ?", nil]).size

 Contract.all(:conditions => ["voided is not ?", nil]).size
Salil