Let's find records where column is NULL
or empty using Active Record
Article.where(topic: [nil, ""])
Let's now find records where column is NOT NULL
or empty using Active Record
Article.where.not(topic: [nil, ""])
This Active Record expression will be converted to the following SQL query.
SELECT "articles.*"
FROM "articles"
WHERE
NOT (("articles"."topic" = '' OR "articles"."topic" IS NULL))