Complete the code to select all users with age greater than 20.
users = User.where("age [1] 20")
The where method filters records. Using age > 20 selects users older than 20.
Complete the code to pluck the names of all users.
names = User.[1](:name)select returns full objects, not just values.where filters records but doesn't extract values.The pluck method extracts a single column's values directly from the database.
Fix the error in the code to select users with name 'Alice'.
users = User.where(name: [1])In Ruby, string values in hashes should be quoted with single or double quotes. Here, 'Alice' is correct.
Fill both blanks to select users older than 30 and pluck their emails.
emails = User.where("age [1] 30").[2](:email)
select returns full objects, not just emails.Use where("age > 30") to filter users older than 30, then pluck(:email) to get their emails.
Fill all three blanks to select users with age less than 25, order by name, and pluck their ids.
ids = User.where("age [1] 25").[2](:name).[3](:id)
where instead of order for sorting.select instead of pluck for extracting ids.Filter users with age < 25, order them by name, then pluck their id values.