我希望范围cancelled_at
为空或空/空白的所有记录。
我发现很多帖子都要求IS NOT NULL /空/空白......但我需要相反。
我确信这很简单,但我很难过。
这是我目前得到的:
scope :active, where("cancelled_at IS NULL")
答案 0 :(得分: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) = '')