For this morning's todo, you'll be creating the following tables: 'costumes','costume_stores', and 'haunted_houses'. You be creating the following classes: Costume
, CostumeStore
, and HauntedHouse
. Each table will have three columns.
The costumes
table will have:
- name
- price
- size
The costume_stores
table will have:
- name
- location
- number of costumes, or "costume inventory"
The haunted_houses
table will have:
- name
- location
- theme
You will only be altering code in six files, the three files in the models
folder and the three files in the db/migrations
folder.
├── app
│ └── models
│ ├── costume.rb
│ ├── costume_store.rb
│ └── haunted_house.rb
└──db
└── migrations
├── 001_create_costumes.rb
├── 002_create_costume_stores.rb
└── 003_create_haunted_houses.rb
This is a test-driven lab so start with the first test and work your way down.
Your models should be no longer than two lines of code.
- The first step is to run
bundle install
. - Create the Costume class in
app/models/
. - Fill out the ActiveRecord migration for costumes such that it passes the specs.
- Create the CostumeStore class in
app/models/
. - Fill out the ActiveRecord migration such that it
costume_stores
the specs. - Create the HauntedHouse class in
app/models/
. - Fill out the ActiveRecord migration for haunted_houses such that it passes the specs.
- Remember to run
rake db:migrate
every time you create a migration. - Just like for any other lab, run
rspec
to view your progress.
- ActiveRecord Migrations
- Just look at the code for the example migrations
- Creating Active Record Models
- Timestamps
View ActiveRecord Costume Store on Learn.co and start learning to code for free.