Query Methods
Retrieval Methods
all
users = User.all # All users
users = User.where(active: true).all # Filteredfirst
user = User.first # First by primary key
user = User.order(name: :asc).first # First alphabetically
user = User.where(active: true).first # First activelast
find
find_by
take
Filtering
where
where.not
or
Ordering
order
reorder
reverse_order
Limiting
limit
offset
Selection
select
distinct
pluck
ids
Aggregation
count
sum
average
minimum
maximum
Grouping
group
having
Joining
join
left_join
includes
Existence
exists?
any?
none?
empty?
Batch Processing
find_each
in_batches
Scopes
scope
Chaining
Raw SQL
query
exec
See Also
Last updated
Was this helpful?
