Sarah Tanembaum
1/12/2005 7:56:00 AM
I follow the Ruby on Rail documentation, it works up to list method.
All other example prior to this works!
Under "Displaying the items: part I", I added the following line in the
app\controllers\todo_controller.rb
def list
end
And when I reload my browser, or point my browser to
http://localhost:3000/todo/list, it gives me ?template missing? page.
So far so good, as expected.
Next, I follow the tutorial to create a blank file in create a blank
file in app\views\todo\ called list.rhtml. As instructed, I reloaded my
browser and sure it is I got a blank page as expected.
Next, I copied the following into the list.rhtml file,
<html>
<head>
<title>My todo list</title>
</head>
<body>
<% @items.each do |@item| %>
<%= @item.description %>
<br />
<% end %>
</body>
</html>
I save it, and reload my browser. Instead of getting the exptected
result, that is "Do my bed", I got a blank page as well.
1) Has this tutorial been tested on Windows environment?
2) Is it because that windows use blackslash(\) for directory separator
instead of Unix forward slash(/)?
3) So, I did a little experiment, I try to execute the list.rhtml using
erb from console, "erb app\views\todo\list.rhtml".
It gives me the following error,
(erb):7: undefined method `each' for nil:NilClass (NoMethodError)
but then, I remember I have eruby for mswin version 1.04, so just to
check it out, I tried with it as well,
"eruby app\views\todo\list.rhtml"
It still give me the same error as above, plus other things:
7: undefined method `each' for nil:NilClass (NoMethodError)
--- generated code ---
print "<html>\n"
print " <head>\n"
print " <title>My todo list</title>\n"
print " </head>\n"
print "\n"
print " <body>\n"
print " "; @items.each do |@item| ; print "\n"
print " "; print(( @item.description )); print "\n"
print " <br />\n"
print " "; end ; print "\n"
print " </body>\n"
print "</html>\n"
----------------------
So, is it something todo with erb or eruby? As far as I can
remember, the .rhtml file is eruby file.
How do I correct this problem, otherwise I can even continue to
explore Ruby On Rails, because I can't even pass the simplest
tutorial.
Hellllp!
Thanks