Railsの学習(MODELS TASTE LIKE CHICKEN)
前回に引き続き、RailsForZombies(http://railsforzombies.org/)をやりました。
今回は、Level2のMODELS TASTE LIKE CHICKENです。
Level 2 Challenges
問題1 Create Model
Define a Zombie model
解答例
問題2 Validations 1
Add a validation that checks for the presence of a Zombie's name
解答例
問題3 Validations 2
Add a validation that checks for the uniqueness of a Zombie's name
解答例
問題4 Validations 3
Do both uniqueness and presence validation on a Zombie's name on a single line, using the new syntax
解答例
問題5 Belongs To
A Weapon should belong to a Zombie. Create that relationship
解答例
問題6 Relationship Find
Resources
zombies
| id | name | graveyard |
| 1 | Ash | Glen Haven Memorial Cemetary |
| 2 | Bob | Chapel Hill Cemetary |
weapons
| id | name | strength | zombie_id |
| 1 | Hammer | 1 | 1 |
| 2 | Chainsaw | 3 | 2 |
Assuming the models and relationships are properly defined, find all the weapons that belong to Zombie Ash