Allow People To Vote
Goals
Steps
Step 1: Add a new route for voting
resources :topics
resources :topics do member do post 'upvote' end endStep 2: Add a new controller action for voting
def upvote @topic = Topic.find(params[:id]) @topic.votes.create redirect_to topics_path, notice: "Topic was successfully created." endStep 3: Add the button to the view
<p> <strong>Votes:</strong> <%= pluralize(topic.votes.count, "vote") %> <%= button_to '+1', upvote_topic_path(topic), method: :post %> </p> </div>Step 4: Confirm your changes in the browser
Now would be a good time to commit to git
Next Step:
Go on to Make The Topic Title A Link