where句全体を反転させて取得
適応バージョン
- 7.0.0
説明
where句全体を反転させて取得
使い方
where句.invert_where()
例
where句全体を反転させて取得
User.where(accepted: true)
# WHERE `accepted` = 1
User.where(accepted: true).invert_where
# WHERE `accepted` != 1
scopeを指定
class User
scope :active, -> { where(accepted: true, locked: false) }
end
User.active
# WHERE `accepted` = 1 AND `locked` = 0
User.active.invert_where
# WHERE NOT (`accepted` = 1 AND `locked` = 0)