I followed the suggestions and encountered 3 problems so far.
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
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.
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:
6:
The html codes for Edit from <Form â?¦ to in both â??cookbookâ? and
â??cookbook2â? are almost identical. Even after I amended the codes to be
identical with the pre-installed, the problem persisted.
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.
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).
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
Thanks. 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.
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.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.