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
On Wed, 12 Jan 2005 02:57:58 -0500, Sarah Tanembaum <sarahtanembaum-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> 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 >Yes, the .rhtml files use eruby for processing. You get the error when running list.rhtml directly because it has no idea what @items is. Running it directly doesn''t load up ActiveRecord, ActionPack, etc. Is there any HTML source being generated when you view the page in the browser? Does the title get displayed? What do your logs say?
On Wed, 2005-01-12 at 02:57 -0500, Sarah Tanembaum wrote:> 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.I''m guessing based on the port 3000 in the URL above that you are using webrick. With that in mind, I am guessing you need to restart webrick as it has probably cached your empty list.rhtml file. Upon restarting webrick, it will reload the list.rhtml file and display as you expect. -- Steven Critchfield <critch-wQLwMjUOumVBDgjK7y7TUQ@public.gmane.org>
Sarah, When you updated your list.rhtml file the second time did you also redo def list end to create @items? i.e. def list @items = Todo.find_all end Also: "Has this tutorial been tested on Windows environment?" All I can say is that I did the tutorial the other night. That was on a Windows box (XP SP2) with Ruby One-Click installer and Rails installed via Gems, running via Webrick. Rob
It may be a silly question, but at the ''scaffold'' part, did you remember to create any new Todo item? On Wed, 12 Jan 2005 08:42:05 +0000, Robert McGovern <robert.mcgovern-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Sarah, > > When you updated your list.rhtml file the second time did you also redo > > def list > end > > to create @items? > > i.e. > > def list > @items = Todo.find_all > end > > Also: "Has this tutorial been tested on Windows environment?" > > All I can say is that I did the tutorial the other night. That was on > a Windows box (XP SP2) with Ruby One-Click installer and Rails > installed via Gems, running via Webrick. > > Rob > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Hi Sarah, if you read this page [http://manuals.rubyonrails.com/read/chapter/38#page107] of the tutorial, you''ll notice that just below the screenshot I say: "If you added any items while you played with scaffolding, you should see them displayed, if you didn''t, go to http://localhost:3000/todo/new and add an item." The reason you are not getting any information shown is because there is none to be shown. Go to the URL mentionned above, add an item called "Do my bed" or whatever you like, save it, and if you go back to http://localhost:3000/todo/list, you will see it. And as the author of this tutorial, I would like to know if other people stumbled upon this problem? If so, I''ll just remove this line and tell people to add an item after they''ve done scaffolding. Vincent. On Wed, 12 Jan 2005 02:57:58 -0500, Sarah Tanembaum <sarahtanembaum-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> 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 > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Vincent Foley-Bourgon Blog: http://www.livejournal.com/~gnuvince World.run while (6 * 9 == 42)
Vincent Foley wrote:> Hi Sarah, > > if you read this page > [http://manuals.rubyonrails.com/read/chapter/38#page107] of the > tutorial, you''ll notice that just below the screenshot I say: > > "If you added any items while you played with scaffolding, you should > see them displayed, if you didn''t, go to > http://localhost:3000/todo/new and add an item." > > The reason you are not getting any information shown is because there > is none to be shown. Go to the URL mentionned above, add an item > called "Do my bed" or whatever you like, save it, and if you go back > to http://localhost:3000/todo/list, you will see it. > > And as the author of this tutorial, I would like to know if other > people stumbled upon this problem? If so, I''ll just remove this line > and tell people to add an item after they''ve done scaffolding. > > Vincent. > > > On Wed, 12 Jan 2005 02:57:58 -0500, Sarah Tanembaum > <sarahtanembaum-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: > >>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 >> >>_______________________________________________ >>Rails mailing list >>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>http://lists.rubyonrails.org/mailman/listinfo/rails >> > > >That was it, thanks. I did forgot to create a new entry using the http://localhost:3000/todo/new. Once I created it, I breeze thru the tutorial without problems. I just have to get used to with the idea of MVC(Model View Controller) mindset. It was an excellent tutorial! Bravo. I''m looking forward for the next step, perhaps a simple apps that we can use it for broader audience, e.g. photoalbum. I''ve been meaning to create a family photoalbum using Ruby. It is an interesting project for me and at the same time, I''ve got a chance to learn Ruby and perhaps Ruby on Rails. Thanks guys.
I have updated the page http://wiki.rubyonrails.com/rails/show/HowtoChangeSessionOptions on storing sessions with ActiveRecordStore with the following lines> In order to improve performance, you might also want to make the sessid and data > fields just as big as the values you will store in the session. For example, if you > know that the length of the session id values is 32 and you only want to store user > ids with length up to 64 you can use a statement like this one:CREATE TABLE sessions { id INTEGER PRIMARY KEY, sessid CHAR(32), data VARCHAR(64) } hope that helps and that scott agrees? -- stefan
Stefan Kaes
2005-Jan-13 08:51 UTC
updated page on storing sessions with ActiveRecordStore (correction)
Oops! I just discovered that the flash is also stored in the session. So the data field must be must be somewhat longer and you might just leave it as text. I''ll correct it in a minute. Apologies to all. -- stefan