|
2 | 2 | goals { |
3 | 3 | goal "Create a model for votes" |
4 | 4 |
|
5 | | - model_diagram header: 'Votes', fields: %w(id topic_id) |
| 5 | + div(style: 'margin: 0 auto; width: 250px; height: 120px;') do |
| 6 | + model_diagram header: 'Topics', fields: %w(id title description), style: "float: left;" |
| 7 | + div(style: 'float: left; position: relative; width: 60px; height: 100px;') do |
| 8 | + div(class: 'arrow-left', style: 'left: 0; top: 30px;') |
| 9 | + div(class: 'horiz-line', style: 'left: 5px; top: 37px; width: 25px;') |
| 10 | + div(class: 'vert-line', style: 'left: 30px; top: 38px; height: 25px;') |
| 11 | + div(class: 'horiz-line', style: 'right: 0; top: 62px; width: 30px;') |
| 12 | + end |
| 13 | + model_diagram header: 'Votes', fields: %w(id topic_id), style: "float: left;" |
| 14 | + end |
6 | 15 |
|
7 | | - message "Every topic in suggestotron can be voted on. In order to count votes, we need to record votes. We'll add that table now." |
| 16 | + message <<-MARKDOWN |
| 17 | + Every topic in suggestotron can be voted on. |
| 18 | + In order to count votes, we need to record votes in the database. |
| 19 | + We'll add the new table for votes now. |
| 20 | + MARKDOWN |
8 | 21 | } |
9 | 22 |
|
10 | 23 | steps { |
11 | 24 | console <<-SHELL |
12 | | -rails generate model vote topic_id:integer |
| 25 | +rails generate model vote references:topic |
13 | 26 | rails db:migrate |
14 | 27 | SHELL |
15 | 28 | } |
16 | 29 |
|
17 | 30 | explanation { |
18 | 31 | message <<-MARKDOWN |
19 | 32 | * Just like before, we're creating a new model named "vote" |
20 | | - * The only thing really different is the integer we added called `topic_id`. |
21 | | - * `topic_id` is the data we need to draw the line between votes and topics. |
| 33 | + * `votes` contains just one thing: a reference to the topic it belongs to |
22 | 34 | * We didn't generate a full scaffold this time because we aren't |
23 | 35 | going to do the full CRUD for votes; they're just going to be |
24 | 36 | considered part of topics as-is. |
|
0 commit comments