For the first, use the hash syntax:
scope :notbilled, where(:invoice_id => nil)
The second requires that you use raw sql:
scope :billed, where('invoice_id is not null')
You can also jump into isl for the second to avoid writing raw sql, but this is an extended topic and will end up being less readable than the original sql.
Using direct equality will not work, because these expressions are evaluated immediately and turn into their logical equivalents, because no variables are involved, therefore they will be interpreted as
scope :notbilled, where(false) scope :billed, where(true)
x1a4
source share