Hear us Roar
Article:
 |
|
Rolling with Ruby on Rails Revisited, Part 2
|
| Subject: |
|
Get problem with recipe/list.rhtml |
| Date: |
|
2007-11-20 12:42:51 |
| From: |
|
EchoGao
|
|
|
|
Hello,
I tried to resolve this problem for several hours but still didn't get the right result.
i tried to change 'recipe.category.name' to 'recipe.category_id', and it shows only a number in Category column of Recipe list.
NoMethodError in Recipe#list
Showing app/views/recipe/list.rhtml where line #13 raised:
undefined method `category' for #<Recipe:0x56b69bc>
Extracted source (around line #13):
10: <td><%= link_to %Q{#{recipe.title}}, :action => 'show', :id => recipe %>
11: <%= link_to '(delete)', {:action => 'destroy', :id => recipe },
12: :confirm => 'Are you sure?', :post => true %></td>
13: <td><%= link_to %Q{#{recipe.category.name}},
14: {:action => 'list', :category_id => recipe.category.id} %></td>
15: <td><%=h recipe.date %></td>
16: </tr>
thanks alot!
|
Showing messages 1 through 1 of 1.
-
Get problem with recipe/list.rhtml
2007-11-20 13:01:30
EchoGao
[View]
|
| |
i find out where i made stupid mistakes.
i forgot to define the relationships between recipe and category in recipe.rb and category.rb.
:)
have a nice day!