SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simply Rails 2, Stuck on Page 226 (day 2)

    Working my way through the Simply Rails 2 book and I am stuck on page 226 with RJS templates.

    I'm trying to update the voting score thats displayed on the page and highlight it with a visual effect using a RJS template.

    Everything works fine until I rename my create.html.erb file to create.rjs and modify it with the following code:

    Code Ruby:
    page.replace_html 'vote_score', "Score: #{@story.votes.size}"
    page[:vote_score].visual_effect :highlight

    After trying to submit a vote the browser displays this error:

    try {
    Element.update("vote_score", "Score: 21");
    $("vote_score").visualEffect("highlight");
    } catch (e) { alert('RJS error:\n\n' + e.toString()); alert('Element.update(\"vote_score\", \"Score: 21\");\n$(\"vote_score\").visualEffect(\"highlight\");'); throw e }


    Can anyone help me out with this? I would really appreciate it!

  2. #2
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had same problem. I had mistake in the story.rb file and the votes_controller was missing an end.( I just finally copied the ones in the archive) It appears to work in browser now but the tests FAIL! says method latest isn't defined! I also noticed windows is saving rjs files as audio files--wonder if that could be the problem. At any rate Chapter 7 just isn't working right at all.

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)
    I too had trouble with the rjs file on Windows. I had to go to Settings -> Folder Options -> File Types and go to "RealSystem Skins" and remove the "open" file<->extension association. It seems that Windows was putting priority on that and not letting Rails get at it. (BTW doing so didn't break the player AFAIK, but you should keep the info for the opening app just in case).

    Code Ruby:
      has_many :votes do
        def latest
          find :all, :order => 'id DESC', :limit => 3
        end
      end
    is in the app\models\story.rb file.


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
  •