newbie: has_many

I am sorry for the newbie question, but I am really stuck and I can't
work it out. :frowning: Have 2 models. category and product (has_many and

My routes.rb:
map.resources :categories do |category|
   category.resources :products

index in category controller:
def index
   @category = Category.find(params[:id])
   @products = @category.products

and then in my index.rhtml:

<% for product in @products %>
<%= product.title %>....
<% end %>

and change to:

<% @products.each do |product| %>

it will end up with this error:
undefined method `title' for #<Class:0x54eb998>

I am sure the title is column name in my table. I can create a new
product, edit it, delete it, but I am not able to show the data

Can anyone help me? Thanks in advance.

You're saying/showing CategoryController, but do you mean ProductsController?

Since the undefined 'title' is attributed to #<Class:...> and not #<Product:...> do you have a naked title somewhere that's being interpreted as a method call on the anonymous view class? Is that the correct line from the view?


Rob Biedenharn