Still Stumbled on First things in trying RubyOnRails http://www.digitalmediaminute.com/article/1816/top-ruby-on-rails-tutorials http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html http://instantrails.rubyforge.org/tutorial/index.html http://rails.homelinux.org/ I had tried the first of the top 12 tutorials and got stuck after adding a new field ?category_id?in the table recipes, introduced C:\InstantRails-1.0\rails_apps\cookbook2\app\views\recipe\edit.rhtml, and modified C:\InstantRails-1.0\rails_apps\cookbook2\app\controllers\recipe_controller C:\InstantRails-1.0\rails_apps\cookbook2\app\models\category C:\InstantRails-1.0\rails_apps\cookbook2\app\models\recipe I log into http://localhost:3000/category/list, chose an item, and when I hit the ?Edit? button, error message occurred. I then went on to modify C:\InstantRails-1.0\rails_apps\cookbook2\app\views\recipe\list C:\InstantRails-1.0\rails_apps\cookbook2\app\views\recipe\edit And now I couldn?t even log into http://localhost:3000/category/list. After some discussions in the forum, I removed the database, re-created a database ?cookbook2? that resembled ?cookbook?, and copied all the codes from ?cookbook? into the ?cookbook2? directory. With the full set of codes in place, and a new, empty database, I went about creating, editing, deleting categories. No problems. I went on to create, edit, and delete recipes. No problems. My conclusion; with the full codes in place, even starting from an empty database, the application is working fine. After that, I removed the database, and the ?cookbook2? directory, and re-run the tutorial from scratch. You know what, the same old problems occurred at the point when ?Edit? was introduced. Introducing the field ?category_id? and changing C:\InstantRails-1.0\rails_apps\cookbook2\app\models\category and C:\InstantRails-1.0\rails_apps\cookbook2\app\models\recipe is a bit like introducing a field with foreign-key contrainst. Would mySQL automatically fill up this field in the exisitng records when the amended codes are run? If not, how do I fill in the blanks? The tutorial had been there for many months, and I am sure many people had taken it and there was no complaint. So, what did I do wrong? Why me? I would be grateful if some one would help. After that, I went on to try ?Four Days on Rails? tutorial. I was stuck because I don?t know how to introduce the Apache that is required. So I used the InstantRails 1.0 that is already installed. When I tried to log on http://todo/ I didn?t get the expected ?Congratulations ?? As I had changed the port in Apache Configuration to 4001, and Apache is listening to Port 80, I couldn?t go any further. When I changed the Apache port back to 80, Apache couldn''t started. Error message said that Port 80 is used by some other process. As you can see by now, I am new to the Apache, mySQL, and even a bit shy in Java Runtime, is it possible for some one to guide me through the initial set-up and installation of Ruby, Rails, Apache, and mySQL including the setting and changing of environment variables, path, lib, etc, so that I can get into tutorials like the top 12? Your assistance will be appreciated. Ling. -- Posted via http://www.ruby-forum.com/.
William (Bill) Froelich
2006-May-09 14:31 UTC
[Rails] Still Stumbled on First things in trying RubyOnRails
> -----Original Message----- > From: rails-bounces@lists.rubyonrails.org > [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Ling > Sent: Tuesday, May 09, 2006 1:03 AM > To: rails@lists.rubyonrails.org > Subject: [Rails] Still Stumbled on First things in trying RubyOnRails > > Still Stumbled on First things in trying RubyOnRails > > http://www.digitalmediaminute.com/article/1816/top-ruby-on-rai > ls-tutorials > > http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html > > http://instantrails.rubyforge.org/tutorial/index.html > > http://rails.homelinux.org/ > > > I had tried the first of the top 12 tutorials and got stuck > after adding a new field "category_id"in the table recipes, > introduced > C:\InstantRails-1.0\rails_apps\cookbook2\app\views\recipe\edit.rhtml, > and modified > C:\InstantRails-1.0\rails_apps\cookbook2\app\controllers\recip > e_controller > C:\InstantRails-1.0\rails_apps\cookbook2\app\models\category > C:\InstantRails-1.0\rails_apps\cookbook2\app\models\recipe > > I log into http://localhost:3000/category/list, chose an > item, and when I hit the "Edit" button, error message occurred.I''ve walked through the tutorial using InstantRails without any problems. Can you provide me more details on the error (Feel free to contact me off list if you want) and I''ll see if I can help.> > I then went on to modify > C:\InstantRails-1.0\rails_apps\cookbook2\app\views\recipe\list > C:\InstantRails-1.0\rails_apps\cookbook2\app\views\recipe\edit > > And now I couldn''t even log into http://localhost:3000/category/list. > > After some discussions in the forum, I removed the database, > re-created a database "cookbook2" that resembled "cookbook", > and copied all the codes from "cookbook" into the "cookbook2" > directory. > > With the full set of codes in place, and a new, empty > database, I went about creating, editing, deleting > categories. No problems. > > I went on to create, edit, and delete recipes. No problems. > > My conclusion; with the full codes in place, even starting > from an empty database, the application is working fine. > > After that, I removed the database, and the "cookbook2" > directory, and re-run the tutorial from scratch. > > You know what, the same old problems occurred at the point > when "Edit" > was introduced. > > Introducing the field "category_id" and changing > C:\InstantRails-1.0\rails_apps\cookbook2\app\models\category > and > C:\InstantRails-1.0\rails_apps\cookbook2\app\models\recipe is > a bit like introducing a field with foreign-key contrainst. > > Would mySQL automatically fill up this field in the exisitng > records when the amended codes are run? > > If not, how do I fill in the blanks? > The tutorial had been there for many months, and I am sure > many people had taken it and there was no complaint. > > So, what did I do wrong? Why me? > > I would be grateful if some one would help. > > After that, I went on to try "Four Days on Rails" tutorial. > > I was stuck because I don''t know how to introduce the Apache > that is required. So I used the InstantRails 1.0 that is > already installed.For fun, I am currently going through this one as well but am trying to use the latest stuff in part to see what has changed ;-) and I am using InstantRails 1.3.> > When I tried to log on http://todo/ I didn''t get the expected > "Congratulations ..."The first this I did was not use Apache. I find it too cumbersome for this type of stuff. The included WEBrick server works just fine. If you startup your app using c:\InstantRails\rails_apps\todo> ruby script\server This will startup the server on port 3000 and you can then reference the todo stuff using http://localhost:3000/ to get the main welcome page. Then to get to your application use: http://localhost:3000/category instead of http://todo/category as indicated in the tutorial (at the top of page 6).> > As I had changed the port in Apache Configuration to 4001, > and Apache is listening to Port 80, I couldn''t go any further. > > When I changed the Apache port back to 80, Apache couldn''t started. > Error message said that Port 80 is used by some other process. > > As you can see by now, I am new to the Apache, mySQL, and > even a bit shy in Java Runtime, is it possible for some one > to guide me through the initial set-up and installation of > Ruby, Rails, Apache, and mySQL including the setting and > changing of environment variables, path, lib, etc, so that I > can get into tutorials like the top 12? > > Your assistance will be appreciated. > > Ling. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Ling
2006-May-09 15:52 UTC
[Rails] Re: RE: Still Stumbled on First things in trying RubyOnRails
Thanks, Bill. I have replied by email, thus taking this off the Forum Regards, Ling. William (Bill) Froelich wrote:>> ls-tutorials >> introduced >> C:\InstantRails-1.0\rails_apps\cookbook2\app\views\recipe\edit.rhtml, >> and modified >> C:\InstantRails-1.0\rails_apps\cookbook2\app\controllers\recip >> e_controller >> C:\InstantRails-1.0\rails_apps\cookbook2\app\models\category >> C:\InstantRails-1.0\rails_apps\cookbook2\app\models\recipe >> >> I log into http://localhost:3000/category/list, chose an >> item, and when I hit the "Edit" button, error message occurred. > > I''ve walked through the tutorial using InstantRails without any > problems. Can you provide me more details on the error (Feel free to > contact me off list if you want) and I''ll see if I can help. > >> directory. >> After that, I removed the database, and the "cookbook2" >> a bit like introducing a field with foreign-key contrainst. >> I would be grateful if some one would help. >> >> After that, I went on to try "Four Days on Rails" tutorial. >> >> I was stuck because I don''t know how to introduce the Apache >> that is required. So I used the InstantRails 1.0 that is >> already installed. > > For fun, I am currently going through this one as well but am trying to > use the latest stuff in part to see what has changed ;-) and I am using > InstantRails 1.3. > >> >> When I tried to log on http://todo/ I didn''t get the expected >> "Congratulations ..." > > The first this I did was not use Apache. I find it too cumbersome for > this type of stuff. The included WEBrick server works just fine. > > If you startup your app using > > c:\InstantRails\rails_apps\todo> ruby script\server > > This will startup the server on port 3000 and you can then reference the > todo stuff using > > http://localhost:3000/ > > to get the main welcome page. Then to get to your application use: > > http://localhost:3000/category > > instead of http://todo/category as indicated in the tutorial (at the top > of page 6).-- Posted via http://www.ruby-forum.com/.
topher
2006-May-09 18:30 UTC
[Rails] Re: Still Stumbled on First things in trying RubyOnRails
> I log into http://localhost:3000/category/list, chose an item, and when > I hit the ?Edit? button, error message occurred.Write the error message here so it would be easier to identify the problem.> After that, I went on to try ?Four Days on Rails? tutorial. > > I was stuck because I don?t know how to introduce the Apache that is > required. So I used the InstantRails 1.0 that is already installed. > > When I tried to log on http://todo/ I didn?t get the expected > ?Congratulations ?? >You don''t have to use Apache. I used WEBrick from InstantRails and I finished the ?Four Days on Rails? tutorial. Just remember that you can only use WEBrick with one app at a time. To run WEBrick, type ruby script\server in the todo directory. Then go to http://localhost:3000. You can use phpMyAdmin (which is included in InstantRails) for creating your database and tables. Go to http://localhost/mysql. Make sure apache is running. It automatically starts when you start InstantRails. Take note that I used two servers when I was reading the tutorial. WEBrick is used for the ToDo app, and Apache is used for phpMyAdmin. I also tried using Apache for my web apps and it worked, but WEBrick is fine and I think is even recommended. -topher -- Posted via http://www.ruby-forum.com/.
Ling
2006-May-09 18:57 UTC
[Rails] Re: Still Stumbled on First things in trying RubyOnRails
topher wrote:> Write the error message here so it would be easier to identify the > problem.Thanks. I have un-installed and deleted all. No examples are currently available. A previous error message is reproduced as follows: That gave a url of http://localhost:3000/recipe/edit/1 Together with the error message as follows: RuntimeError in Recipe#edit Showing app/views/recipe/edit.rhtml where line #8 raised: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id Extracted source (around line #8): 5: <body> 6: <h1>Edit Recipe</h1> 7: 8: <form action="../update/<%= @recipe.id %>" method="POST"> 9: <input id="recipe_id" name="recipe[id]" size="30" 10: type="hidden" value="<%= @recipe.id %>" /> 11: <p><b>Title</b><br> RAILS_ROOT: ./script/../config/.. Application Trace | Framework Trace | Full Trace #{RAILS_ROOT}/app/views/recipe/edit.rhtml:8 Request Parameters: {"id"=>"1"} Show session dump --- flash: !map:ActionController::Flash::FlashHash {} Response Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"} It appeared to me that when I made use of the full sets of codes and an empty database, and build up from categories to recipes, everything is working. But if we introduce a new field with foreign key constraint, and modify the codes mid-stream, things start to break down as in the 2 tutorials I tried. I might have missed out some steps, like filling in the category_id, off-line, and then re-start the application. I don''t know. Regards, Ling. -- Posted via http://www.ruby-forum.com/.
topher
2006-May-10 17:51 UTC
[Rails] Re: Still Stumbled on First things in trying RubyOnRails
> That gave a url of http://localhost:3000/recipe/edit/1 > > Together with the error message as follows: > > RuntimeError in Recipe#edit > Showing app/views/recipe/edit.rhtml where line #8 raised: > Called id for nil, which would mistakenly be 4 -- if you really wanted > the id of nil, use object_id > Extracted source (around line #8): > 5: <body> > 6: <h1>Edit Recipe</h1> > 7: > 8: <form action="../update/<%= @recipe.id %>" method="POST"> > 9: <input id="recipe_id" name="recipe[id]" size="30" > 10: type="hidden" value="<%= @recipe.id %>" /> > 11: <p><b>Title</b><br> > RAILS_ROOT: ./script/../config/.. > Application Trace | Framework Trace | Full Trace > #{RAILS_ROOT}/app/views/recipe/edit.rhtml:8 > Request > Parameters: {"id"=>"1"} > Show session dump > --- > flash: !map:ActionController::Flash::FlashHash {} > > Response > Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"} >I think the error means that @recipe in line 8 is nil when it shouldn''t be. Check the edit method in recipe_controller.rb.> It appeared to me that when I made use of the full sets of codes and an > empty database, and build up from categories to recipes, everything is > working. > > But if we introduce a new field with foreign key constraint, and modify > the codes mid-stream, things start to break down as in the 2 tutorials I > tried. > > I might have missed out some steps, like filling in the category_id, > off-line, and then re-start the application. > > I don''t know. >You probably missed a few steps. Adding new columns and even foreign keys on your tables shouldn''t be a problem in Rails. Just put belongs_to and has_many and Rails will handle everything. Here are the steps you should pay attention to. 1. create category_id field in the recipes table. type should be the same as id in the category table 2. edit recipe and category models. put belongs_to and has_many 3. in recipe_controller.rb, write the edit method 4. create edit.rhtml Then test your app. Good luck. -topher -- Posted via http://www.ruby-forum.com/.
Ling
2006-May-10 20:18 UTC
[Rails] Re: Still Stumbled on First things in trying RubyOnRails
topher wrote:> You probably missed a few steps. Adding new columns and even foreign > keys on your tables shouldn''t be a problem in Rails. Just put belongs_to > and has_many and Rails will handle everything. > > Here are the steps you should pay attention to. > 1. create category_id field in the recipes table. type should be the > same as id in the category table > 2. edit recipe and category models. put belongs_to and has_many > 3. in recipe_controller.rb, write the edit method > 4. create edit.rhtml > > Then test your app. > > Good luck. > > -topherThanks. Rails4days I was working through the ?Four days on ROR? tutorial. I was doing fine from day 1 to 2.>From Day 3 onwards there were so many changes. I like the explanations.So, I copied and pasted the codes from the PDF. At the end of the whole process, when I ran the app there were quite a few errors, mostly on wrong syntax, or something in the wrong place or something missing. So, some codes were not copied, or the syntax were wrong as I pasted the amended at wrong places, or put an ?end? where it is not required. I guess I did learn something in the process. At the end, I got impatient. I just copied the downloaded codes into the required directories. It took less than 2 minutes. When I ran the app again, well, it was working. ;-) I thought so, anyway. I noted that the images were represented by X. I then realized I didn?t copy the image files. Since it was late, I switched off the PC and went to bed. The next morning, I hopefully turned on the app. To my horrors, it wasn''t working. In particular, the Webrick was not working properly. I deleted the directory, reinstalled the InstantRails 1.0, and later 1.3. When I copied and pasted only a few modules, in the early part of the tutorial, things worked. When I copied all the down-loaded files and pasted into the directory, nothing seemed to work. Am I supposed to work through the modules step by step, and not encouraged to copy and paste the codes? Can someone help to explain why the Webrick didn?t work? Regards, Ling. -- Posted via http://www.ruby-forum.com/.