Complete the code to find a user by id using Active Record.
user = User.[1](1)
The find method retrieves a record by its primary key in Active Record.
Complete the code to create a new user record with Active Record.
user = User.[1](name: "Alice", email: "alice@example.com")
The create method builds and saves a new record in one step.
Fix the error in the code to update a user's email attribute.
user = User.find(1) user.[1](email: "new@example.com")
The update method changes attributes and saves the record.
Fill both blanks to query users with age greater than 30 and order by name.
users = User.where("age [1] ?", 30).[2](:name)
The where method filters records; use '>' to find ages greater than 30. The order method sorts results by a column.
Fill all three blanks to define a scope named 'active' that selects users with status 'active' and orders by created_at descending.
scope :active, -> { where(status: [1]).[2](created_at: [3]) }The scope filters users with status 'active', orders them by created_at in descending order using order and :desc.