[Rail] 1. CRUD for Rails - Ex
1. To get a Zombie where id = 1:
Zombie.find(1)
2. To get Zombie id = 1,2,3, using one line commend:
Zombie.find(1,2,3)
3. Create a new Zombie: create command can new and save at the same time, it will insert a empty row into the database!
Zombie.create
4. Find the last Zombie
in the database, but don't use IDs
Zombie.last
5. Find all Zombies
ordered by their names.
Zombie.all.order(:name)
6. Update Zombie 3
's graveyard to 'Benny Hills Memorial'
z = Zombie.find(3) z.graveyard = 'Benny Hills Memorial' z.save
7. Destroy the Zombie
with an ID of 3
.
Zombie.find(3).destory