goal "Create a model for votes"
model_diagram header: 'Votes', fields: %w(id topic_id)
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."
rails generate model vote topic_id:integer
* 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.
After running the `rails generate resource` command we are sure you noticed
that it does something really similar to the `rails generate scaffold` command.
The difference is:
* The command `rails generate scaffold <scaffold-name>` generates prepopulated
controllers, views, models and migrations. Also, it hooks up everything together so you
can easily do CRUD (Create, Read, Update, Delete) operations without writing any code.
* The command `rails generate resource <resource-name>` generates empty
controllers, models and migrations (no views!) so you, the programmer, can later write your own
code in those files and customize the behaviour of the application for your needs.
Now that you know what is the difference between scaffold and resource, lets continue with the next step.