AR CRUD Operations

Create

User.create(name: 'Matt', occupation:'Web Dev')

This will create a new User object as well as a new record in your database.

Read

User.all

User.find_by(name: 'Matt')

Update

user = User.find_by(name: 'Matt')

user[:name] = 'Mike'

user.save (This is important because the ruby object is not saved until you run this command)

Delete

user = User.find_by(name: 'Matt')

user.destroy