SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot basicwebus's Avatar
    Join Date
    Jul 2003
    Location
    Missouri
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Simply Rails 2 Ch 7 Fix for the Voting

    I had problems with my voting working correctly after I worked through the book up to page 238. It was not adding the votes when I clicked the shove it button.

    I checked errors on the server command window and found that there was an end missing from the votes_controller.rb file. There must be three end listed there. Even copying the code archive showed only two. After I added the third end at the end of the file it worked. The code that worked is listed below. Hope this helps someone else having this voting problem.

    Code Ruby:
    class VotesController < ApplicationController
      def create
        @story = Story.find(params[:story_id])
        @story.votes.create
     
     respond_to do |format|
       format.html { redirect_to @story }
       format.js
        end
      end
    end
    After the third time of reading the instructions,
    it finally soaks in to my thick skull.



  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,258
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)
    The 14-votes_controller.rb file in the chapter07 folder of the code archive has 3 "end"s.
    Code Ruby:
    class VotesController < ApplicationController
     
      def create
        @story = Story.find(params[:story_id])
        @story.votes.create
        respond_to do |format|
          format.html { redirect_to @story }
          format.js
        end
      end
     
    end
    Maybe the empty line before the last one messed up for you somehow?

  3. #3
    SitePoint Zealot basicwebus's Avatar
    Join Date
    Jul 2003
    Location
    Missouri
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, I didn't think to check the code archive on this one. I like to type the code myself first, see if I can work out the problems, and then if I can't figure it out I check the code archive. Since I was able to figure out the problem, I didn't think to check that file.

    Thanks for letting me know. I checked that file and it sure does have all those end on there!
    After the third time of reading the instructions,
    it finally soaks in to my thick skull.




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •