SitePoint Sponsor |
|
User Tag List
Results 1 to 16 of 16
-
Nov 18, 2005, 19:08 #1
"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!
-
Nov 19, 2005, 04:24 #2
- 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?
-
Nov 19, 2005, 08:20 #3
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..
-
Nov 19, 2005, 09:06 #4
- 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?
-
Nov 19, 2005, 09:13 #5
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..
-
Nov 19, 2005, 09:53 #6
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..
-
Nov 19, 2005, 10:21 #7
- 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?
-
Nov 19, 2005, 10:30 #8
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...
-
Nov 19, 2005, 10:41 #9
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..
-
Nov 19, 2005, 11:39 #10
[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.
-
Nov 19, 2005, 11:49 #11
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
-
Nov 19, 2005, 12:41 #12
- 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?
-
Nov 19, 2005, 12:45 #13
- 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?
-
Nov 19, 2005, 13:22 #14
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!!
-
Nov 21, 2005, 12:11 #15
- 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
-
Dec 17, 2005, 21:14 #16
- Join Date
- May 2001
- Location
- LaGrange, Georgia
- Posts
- 6,117
- Mentioned
- 3 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