Usage of invert_where for inverting entire where clause ๐Ÿ™Œ๐Ÿผ

With Rails 7.0, you can use invert_where to invert an entire where clause instead of manually applying conditions ๐Ÿ’ฃ

Reference - Rails PR #40249

Code snippet ๐Ÿ“Œ

# Version: Rails 7.0

class User
  scope :active, -> { where(is_active: true) }
end

# Before
active_users = User.active
inactive_users = User.where(active: false)

# After
active_users = User.active
inactive_users = User.active.invert_where