Permalink
Browse files

Merge pull request #3 from gvt/master

VotesController (not VotesControllerTest) should inherit from ApplicationController
  • Loading branch information...
2 parents ee250fd + ece7e09 commit c896348ba77294c8d40f1bb8ebc026d11519e0f7 @alexch alexch committed Nov 19, 2011
Showing with 6 additions and 5 deletions.
  1. +4 −4 lessons/14.yaml
  2. +2 −1 lessons/20.yaml
View
@@ -14,7 +14,7 @@ steps: |
<td><%= topic.title %></td>
<td><%= topic.description %></td>
<td><%= pluralize(topic.votes.length, "vote") %></td>
- <td><%= link_to '+1', votes_path(:topic_id => topic.id), :method => :post %></td>
+ <td><%= button_to '+1', votes_path(:topic_id => topic.id), :method => :post %></td>
<td><%= link_to 'Show', topic %></td>
<td><%= link_to 'Edit', edit_topic_path(topic) %></td>
<td><%= link_to 'Destroy', topic, :confirm => 'Are you sure?', :method => :delete %></td>
@@ -25,7 +25,7 @@ steps: |
Add the following method to `Vote` in `app/controllers/votes_controller.rb`:
<pre class="code">
- class VotesControllerTest < ActionController::TestCase
+ class VotesController < ApplicationController
def create
topic = Topic.find(params[:topic_id])
vote = topic.votes.build
@@ -43,10 +43,10 @@ explanation: |
First we added this line to `app/views/topics/index.html.erb`
<pre class="code">
- &lt;td>&lt;%= link_to '+1', votes_path(:topic_id => topic.id), :method => :post %>&lt;/td>
+ &lt;td>&lt;%= button_to '+1', votes_path(:topic_id => topic.id), :method => :post %>&lt;/td>
</pre>
- * `link_to '+1'` creates an html link with the text '+1'
+ * `button_to '+1'` creates an html button with the value '+1'
* `votes_path(:topic_id => topic.id)` creates the right url for the action we want to invoke. In this case, we want to create a vote for the current topic.
* `votes_path(:topic_id => 42)` would output `/votes?topic_id=42`
* `:method => :post` ensures we do the create action of CRUD, not the read action.
View
@@ -8,7 +8,8 @@ steps: |
Again with the terminal:
- $ git commit -m "Made stuff look prettier" .
+ $ git add .
+ $ git commit -m "Made stuff look prettier"
$ git push heroku master
explanation: |

0 comments on commit c896348

Please sign in to comment.