Using Where Queries with Enums

You can use ActiveRecord’s where method for flexible queries:

User.where(status: :inactive)   # Fetch all inactive users
User.where(status: [:active, :banned]) # Fetch active OR banned users

Since enums are stored as integers, you can also filter by their integer values (though this is not recommended):

User.where(status: 1) # Retrieves all inactive users (1 = inactive)