Rails scope for IS NOT NULL and is not empty/blank?

前端 未结 6 595
没有蜡笔的小新
没有蜡笔的小新 2021-01-30 05:20

I have the following scope:

scope :comments, :conditions => [\'text_value IS NOT NULL\']

But I also want the conditions to say \"OR text_val

6条回答
  •  悲哀的现实
    2021-01-30 05:42

    Use text_value <> '' to efficiently cover both cases.

    Will only be TRUE for a text_value that is neither NULL nor empty.

提交回复
热议问题