2

我想限定所有cancelled_atIS NULL 或空/空白的记录。

我发现很多帖子要求 IS NOT NULL/empty/blank ......但我需要相反的。

我敢肯定这很简单,但我很难过。

这是我目前得到的:

scope :active, where("cancelled_at IS NULL")
4

1 回答 1

3

你试过吗?

 Patient.where("created_at IS NULL or CAST(created_at as text) = ''")
 # SELECT "patients".* FROM "patients" WHERE (created_at IS NULL or CAST(created_at as text) = '')
于 2013-01-30T14:11:42.740 回答