| Article: |
Rolling with Ruby on Rails | |
| Subject: | Errors in the end | |
| Date: | 2005-07-08 00:17:20 | |
| From: | PGomez | |
|
I have checked out your code and everything is both the exact same. What I am thinking is that it is something in the database maybe. I am getting two errors, one from each page, edit.rhtml and list.rhtml. From the edit page, I get this:
|
||
Showing messages 1 through 11 of 11.
-
Errors in the end
2005-08-09 18:10:55 jdmce [View]
I have had a very similar problem which I solved on Win2k with Peter's solution below. The curious thing is, when I run the original syntax on WinXP it works. I was using this tutorial as a template/learning experience to write a small message board program. Until I lean more, I have had to create win2k and xp versions!
-
Errors in the end
2005-07-27 12:09:43 acidbox [View]
I am also getting a similar error:
RuntimeError in Recipe#edit
Showing /recipe/edit.rhtml where line #20 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 #20):
17:
18: <select name="recipe[category_id]">
19: <% @categories.each do |category| %>
20: <option value="<%= category.id %>" <%= ' selected' if category.id == @recipe.category.id %>><%= category.name %></option>
21: <% end %>
22: </select>
23:
Does anyone know what this is or how I can fix it? I thought I had triple-checked my code. -
Errors in the end
2005-07-27 12:35:22 acidbox [View]
Fixed the problem.
Basically I had to change this:
<%= ' selected' if category.id == @recipe.category.id %>
to this:
<%= ' selected' if category.id == @recipe.category_id %>
-
Errors in the end
2005-07-27 12:32:34 Curt Hibbs |
[View]
Check your database and make sure all of your recipe entries have valid category ids.
-
Errors in the end
2005-07-08 07:46:22 Curt Hibbs |
[View]
This looks like the same problem that Peter just resolved above in the post "Couldn't find Recipe without an ID". Please try his solution. -
Errors in the end
2005-07-08 13:24:40 PGomez [View]
To get past the list.rhtml page, I omitted the line 18 that states
<td><%= recipe.category.name %></td>
Now it enables me to see the page, but still is not doing me any good since it did not solve the problem. With that, on the edit.rhtml I changed line 24 to:
<%= 'selected' if category.id == @recipe.category_id %>>
Instead of:
<%= 'selected' if category.id == @recipe.category.id %>>
Does that make sense with that second change? Thanks! -
Errors in the end
2006-10-04 05:02:32 rudyOnTheTrain [View]
@recipe.category_id points to the foreign_key in the table recipe called category_id,so it makes perfect sense. @recipe.category.id points to a column that doesn`t exist in the table recipe. -
Errors in the end
2005-10-21 08:41:49 kFuQ [View]
To get past the list.rhtml page, I omitted the line 18 that states
<td><%= recipe.category.name %></td>
chg to
<td><%= recipe.category name %></td> -
Errors in the end
2005-07-08 12:26:24 PGomez [View]
I tried it and still getting the same issue and same errors. I am sorry to be posting this, but still learning and not familiar enough to get this one going. -
Errors in the end
2005-07-08 14:35:26 Curt Hibbs |
[View]
Make sure that every recipe in your database has an assigned category.
Also, near the beginning og part 2 of this article, there is a link to the source code for a working version of part 1 (hopefully it still works since Rails 0.13 was just released). Anyway, you can download my sourcecode and see if that works, and then compare it with what youhave. -
Errors in the end
2005-07-15 12:55:06 zsmirnoff [View]
the column id must be in lowercase - id - not Id, as mysql defines it first, in the database - just change the column name; rails use a lot of concepts about naming


