Complete the code to fetch all users with a single query.
users = User.[1]The all method fetches all records in one query.
Complete the code to eager load associated posts with users.
users = User.[1](:posts)The includes method eager loads associations to reduce queries.
Fix the error in the query to find users older than 30.
users = User.where("age [1] ?", 30)
The operator > correctly filters users older than 30.
Fill both blanks to optimize fetching user emails for active users.
emails = User.where(active: [1]).[2](:email)
Filtering active users with true and using pluck fetches only emails efficiently.
Fill all three blanks to create a hash of user names and their post counts for users with more than 5 posts.
result = User.joins(:posts).group([1]).having("COUNT(posts.id) [2] ?", [3]).count
Grouping by :name, filtering with > 5 posts, and counting returns the desired hash.
