I have tried to learn ruby on rails from scratch by going into a tutorial at the following website. http://instantrails.rubyforge.org/tutorial/index.html I followed the suggestions and encountered 3 problems so far. 1. Couldn''t start the Apache server. Error message "Port 80 was used by some other process." I over-came the problem by going into configuration and change the port to 4001. 2. I couln''t connect to my localhost using the MySQL-Front. I overcame the problem by following the explanation in one website and run RegEdit and changed some setting in the Windows Registration. 3. I copied and pasted the codes for edit.rhtml, and run the example and found that text boxes were not filled with the desired fields, but the source codes instead. I deleted every thing and re-installed every thing, and came to the same problems in "Edit". The error message is now 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> It appears that @recipe is null. Any assistance will be appreciated. Regards Ling -- Posted via http://www.ruby-forum.com/.
On 5/7/06, Ling <ling_l_w@yahoo.com> wrote:> > I have tried to learn ruby on rails from scratch by going into a > tutorial at the following website. > > http://instantrails.rubyforge.org/tutorial/index.html > > I followed the suggestions and encountered 3 problems so far. > 1. Couldn''t start the Apache server. Error message "Port 80 was used by > some other process." I over-came the problem by going > > into configuration and change the port to 4001. > 2. I couln''t connect to my localhost using the MySQL-Front. I overcame > the problem by following the explanation in one > > website and run RegEdit and changed some setting in the Windows > Registration. > 3. I copied and pasted the codes for edit.rhtml, and run the example and > found that text boxes were not filled with the > > desired fields, but the source codes instead. I deleted every thing and > re-installed every thing, and came to the same > > problems in "Edit". > > The error message is now 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> > > It appears that @recipe is null. > > Any assistance will be appreciated. > > Regards > > LingWhat URL were you using when you got this error? The URL will tell you the id of the recipe you are trying to edit. For example if the URL was : http://127.0.0.1:3000/recipe/edit/2 Then you would be trying to edit the recipe with id=2. Once you know the id, go look at your database. Do you have a recipe with that id? If so then there is something wrong with your controller because it should be setting @recipe. Also, Instant Rails comes with a copy of the cookbook application preinstalled. Can you run this one? If so, you can always compare your source code with that. Curt -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060507/cc1b31d5/attachment.html
Thanks for your reply. I first clicked on ?http://localhost:3000/recipe/list? that gave me the display, in website called ?http://localhost:3000/recipe/list? Then I clicked on one of the items, say, the first one in the grid. That gave a url of http://localhost:3000/recipe/show/1 So far, so good. Then I clicked on the ?Edit? button at the bottom: 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"} p.s. The html codes for Edit from <Form ? to </Form> in both ?cookbook? and ?cookbook2? are almost identical. Even after I amended the codes to be identical with the pre-installed, the problem persisted. Regards, Ling. Curt Hibbs wrote:> On 5/7/06, Ling <ling_l_w@yahoo.com> wrote: >> into configuration and change the port to 4001. >> >> Extracted source (around line #8): >> >> Any assistance will be appreciated. >> >> Regards >> >> Ling > > > What URL were you using when you got this error? The URL will tell you > the > id of the recipe you are trying to edit. For example if the URL was : > > http://127.0.0.1:3000/recipe/edit/2 > > Then you would be trying to edit the recipe with id=2. Once you know the > id, > go look at your database. Do you have a recipe with that id? > > If so then there is something wrong with your controller because it > should > be setting @recipe. > > Also, Instant Rails comes with a copy of the cookbook application > preinstalled. Can you run this one? If so, you can always compare your > source code with that. > > Curt-- Posted via http://www.ruby-forum.com/.
Are you able to run the preinstalled version of cookbook? If yes, then there''s got to be some subtle difference between you version and it (either in the code, or in the database). Curt On 5/7/06, Ling <ling_l_w@yahoo.com> wrote:> > > Thanks for your reply. > > I first clicked on "http://localhost:3000/recipe/list" that gave me the > display, in website called "http://localhost:3000/recipe/list" > > Then I clicked on one of the items, say, the first one in the grid. > > That gave a url of http://localhost:3000/recipe/show/1 > > So far, so good. > > Then I clicked on the "Edit" button at the bottom: > > 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"} > > > p.s. > > The html codes for Edit from <Form ? to </Form> in both "cookbook" and > "cookbook2" are almost identical. Even after I amended the codes to be > identical with the pre-installed, the problem persisted. > > Regards, > > Ling. > > > Curt Hibbs wrote: > > On 5/7/06, Ling <ling_l_w@yahoo.com> wrote: > >> into configuration and change the port to 4001. > >> > >> Extracted source (around line #8): > >> > >> Any assistance will be appreciated. > >> > >> Regards > >> > >> Ling > > > > > > What URL were you using when you got this error? The URL will tell you > > the > > id of the recipe you are trying to edit. For example if the URL was : > > > > http://127.0.0.1:3000/recipe/edit/2 > > > > Then you would be trying to edit the recipe with id=2. Once you know the > > id, > > go look at your database. Do you have a recipe with that id? > > > > If so then there is something wrong with your controller because it > > should > > be setting @recipe. > > > > Also, Instant Rails comes with a copy of the cookbook application > > preinstalled. Can you run this one? If so, you can always compare your > > source code with that. > > > > Curt > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060508/14ff10b7/attachment-0001.html
Curt Hibbs wrote:> Are you able to run the preinstalled version of cookbook? If yes, then > there''s got to be some subtle difference between you version and it > (either > in the code, or in the database). > > CurtThanks. Curt. I tried the pre-installed "cookbook" with the exisitng data. I was able to create new categories, new recipes, and edit and delete. No problems. I removed the "cookbook2" database and re-created the database, taking care to see the tables and fields are the same as those in "cookbook" I copied the whole folder App from "cookbook" to "cookbook2" and so the codes are identical. With the empty database, I now tried to display the recipes (none entered as yet), and an error message appeared. So I load the website to enter 3 categories successfully. I then entered into the web page to create a new recipe. The page loaded successfully with 3 items in the drop-down list for categories. I entered data into the text boxes and text-area, and selected one item of category from the drop-down and hit the "Create" button. Unable to save data. Errors encountered. Same as when I tried to display the recipe when there were none. Please advise what to do from now. Regards, Ling. -- Posted via http://www.ruby-forum.com/.
Ling
2006-May-08 05:16 UTC
[Rails] Re: Re: RuntimeError in Recipe#edit/ Found mistake- Resolved
Curt Hibbs wrote:> Are you able to run the preinstalled version of cookbook? If yes, then > there''s got to be some subtle difference between you version and it > (either > in the code, or in the database). > > CurtHi, Curt I found my mistake in the database setting. The field "title" in the table [recipes] doesnot allow null and I set the default to [null]. Once I corrected this mistake, the application is running. Thanks for your advice that led me me to discover the mistake. Now, I can proceed to a new tutorial. Regards, Ling. -- Posted via http://www.ruby-forum.com/.
Curt Hibbs
2006-May-08 08:04 UTC
[Rails] Re: Re: RuntimeError in Recipe#edit/ Found mistake- Resolved
Great! On 5/8/06, Ling <ling_l_w@yahoo.com> wrote:> > Curt Hibbs wrote: > > Are you able to run the preinstalled version of cookbook? If yes, then > > there''s got to be some subtle difference between you version and it > > (either > > in the code, or in the database). > > > > Curt > > > Hi, Curt > > I found my mistake in the database setting. > > The field "title" in the table [recipes] doesnot allow null and I set > the default to [null]. > > Once I corrected this mistake, the application is running. > > Thanks for your advice that led me me to discover the mistake. > > Now, I can proceed to a new tutorial. > > Regards, > > Ling. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060508/f06d983f/attachment.html