Skip to content

Commit 9eb2eaa

Browse files
committed
add voting on topics
1 parent 68f2132 commit 9eb2eaa

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
__IMPORTANT__: this material has been adapted from [railsbridge.org](http://docs.railsbridge.org/intro-to-rails/) to work on the [cloud9 IDE](http://c9.io)
2+
3+
14
# Intro To Rails
25

36
## Goal

setting_the_default_page.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ $ rails console
6767
`app` is a special object that represents your entire application. You can ask it about its routes (as we just did), play with its database connections, or make pseudo-web requests against it with `get` or `post` (and lots more).
6868

6969
## Next Step:
70-
Go on to Voting On Topics
70+
Go on to [Voting On Topics](voting_on_topics.md)

voting_on_topics.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Voting On Topics
2+
3+
## Goals
4+
* Create a model for votes
5+
6+
Votes |
7+
---------|
8+
id |
9+
topic_id |
10+
11+
Every topic in suggestotron can be voted on. In order to count votes, we need to record votes. We'll add that table now.
12+
13+
## Steps
14+
Type this in the terminal (bash):
15+
```bash
16+
rails generate model vote topic_id:integer
17+
rake db:migrate
18+
```
19+
## Explanation
20+
* Just like before, we're creating a new model named "vote"
21+
* The only thing really different is the integer we added called `topic_id`.
22+
* `topic_id` is the data we need to draw the line between votes and topics.
23+
* 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.
24+
## Next Step:
25+
Go on to Hooking Up Votes And Topics

0 commit comments

Comments
 (0)