Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 820 Bytes

voting_on_topics.md

File metadata and controls

26 lines (21 loc) · 820 Bytes

Voting On Topics

Goals

  • Create a model for votes
Votes
id
topic_id

Every topic in suggestotron can be voted on. In order to count votes, we need to record votes. We'll add that table now.

Steps

Type this in the bash tab (aka terminal):

rails generate model vote topic_id:integer
rake db:migrate

Explanation

  • Just like before, we're creating a new model named "vote"
  • The only thing really different is the integer we added called topic_id.
  • topic_id is the data we need to draw the line between votes and topics.
  • We didn't generate a full scaffold this time because we aren't going to do the full CRUD for votes; they're just going to be considered part of topics as-is.

Next Step:

Go on to Hooking Up Votes And Topics