SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Enthusiast Conveyance's Avatar
    Join Date
    Sep 2005
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    "Agile Web Dev with Rails" Book Help??

    Hey everyone! I was excited to see that Sitepoint has this Ruby forum now..

    I'm pretty new to programming (just a little CF) and I picked up this book to learn Ruby on Rails.. The "hello script" tutorial at the beginning of the book has you create a rhtml page and save it in apps/views/say/. Then when you refresh the localhost:3000/say/hello you are supposed to see "Template is Missing" message replaced by your rhtml page..

    I have done this and can't get the error message to go away. I've checked all the spellings for typos, restarted the Webrick server and everything I can think of. Any suggestions?

    I'm on XP and have all the latest versions (downloaded today in fact)

    Thanks in advance for any help!

  2. #2
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You don't have to restart WEBrick, but is the file named hello.rhtml, for localhost:3000/say/hello?

  3. #3
    SitePoint Enthusiast Conveyance's Avatar
    Join Date
    Sep 2005
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I've checked to make sure I have the path correct etc.. Frustrating, I was having so much fun learning this and now I'm stuck!

    Thanks for the advice though..

  4. #4
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is your controller code? Are there any render() calls in the hello() method?

  5. #5
    SitePoint Enthusiast Conveyance's Avatar
    Join Date
    Sep 2005
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The first step was to edit the say_controller to this:

    class SayController < ApplicationController
    def hello
    end
    end


    Then the book said to open up http://localhost:3000/say/hello and I would get the error message "template missing" (which I did!)

    Then the book said to create the app/views/say/hello.rhtml text file and refresh and I would get a hello message, but everytime I refresh I get the same "template missing" message..

  6. #6
    SitePoint Enthusiast Conveyance's Avatar
    Join Date
    Sep 2005
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've tried starting webrick in the "cookbook" directory and running http://localhost:3000/recipes/list and that says template missing as well (and it is right there in the views folder) so that seems like I have my webrick or ruby set up wrong or something?

    Are there any setup settings for either ruby, rails or webrick that I might need to change from the defaults? That's the only thing I can think of..

  7. #7
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try:
    1. render :template => "say/hello" in your controller
    2. render :file => "/absolute/path/to/hello.rhtml"

    Do these work?

  8. #8
    SitePoint Enthusiast Conveyance's Avatar
    Join Date
    Sep 2005
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's my current code in my controller:

    class SayController < ApplicationController
    def hello
    end
    end

    Should I replace the "def hello end" portion of the code with "render :template => "say/hello" OR add that code in after the "def hello end"?

    Actually, I just tried both and they caused error messages...

  9. #9
    SitePoint Enthusiast Conveyance's Avatar
    Join Date
    Sep 2005
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not to REALLY show how new I am to programming/servers, but while searching for a solution to my problem I keep reading about installing Apache in many rubyonrails installation guides. The book I'm working off of never mentions this, I had assumed that webrick would act as my server on my local machine. Should I have apache installed as well? Just an idea..

  10. #10
    SitePoint Addict SRTech's Avatar
    Join Date
    Mar 2005
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    [quote=Conveyance]Should I have apache installed as well? Just an idea..[quote]

    Not if you are just starting. WEBrick will work fine. Apache can handle higher loads, but is much more complex to setup.

  11. #11
    SitePoint Enthusiast Conveyance's Avatar
    Join Date
    Sep 2005
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    good, I didn't want to tackle that, but I thought maybe since I can't get the html pages (views) to display, but it works with ruby code that I might need an external server to serve the rhtml pages..

    But that's cool that I don't. There must be some configuration problem then, because I have downloaded the source files to two other "learn rubyonrails" tutorials, and it can't find the templates on those either (and I know the coding is right in those..)

    Should I reinstall Ruby/Rails/MySql again maybe?

    Thanks again for all the help! (I had hoped to spend today working in this book

  12. #12
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Permissions on the rhtml file?

    (It sounds to me like you are doing things correctly, I think you've just stumbled onto an uncommon snag.)
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  13. #13
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fenrir2 is suggesting you try:

    class SayController < ApplicationController
    def hello
    render :template => "say/hello"
    end
    end

    class SayController < ApplicationController
    def hello
    render :file => "/absolute/path/to/hello.rhtml"
    end
    end

    Worth a shot, should take you a few seconds to try each.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  14. #14
    SitePoint Enthusiast Conveyance's Avatar
    Join Date
    Sep 2005
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, wow, you guys are gonna kill me...


    I created the rhtml file in notepad like I do all my html documents, and it was adding hello.rhtml.txt to the file name. It didn't display anything more than hello.rhml in my explorer window, but when I right-clicked the rhtml file and looked at the properties, it had hello.rhtml.txt as the file name..

    So I had to go download scite editor to create the rhtml page, which now doesn't have the .txt after the .rhtml

    Now it works fine.. Thanks everybody for the help!!

  15. #15
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Location
    Norway
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can set your own extension in Notepad too...in th save dialog, the dropdown with extension can be changed from text to something like "All extensions", if you do that you can put an extension on the file yourself. I believe. I haven't used Windows that much in a while. But anyway if you are happy with Scite, use it.

    /offtopic

  16. #16
    SitePoint Wizard silver trophy
    beley's Avatar
    Join Date
    May 2001
    Location
    LaGrange, Georgia
    Posts
    6,117
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Advice -> Turn off "hiding known file extensions"

    Go to Tools -> Folder Options (from within any Explorer window)

    Make sure that "Show hidden files/folders" is checked
    Make sure that "Hide extensions for known file types" is UNchecked

    And I also prefer

    Check "Display the full path in the address bar" (so you can see where you are all the time)


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
  •