Navigation Problems


I am having problems with my page. I have a banner and navigation bar in
controller_name.rhtml in app/views/layout. Can someone please help?

In the navigation bar, I have the following links:


In the main content, I have the following links:

  Sub-Category1 edit delete
  Sub-Category2 edit delete
  Sub-Category3 edit delete
  Sub-Category4 edit delete
  Sub-Category5 edit delete
  Sub-Category6 edit delete

When I click the Sub_Category link in either the navigation bar or the
main content, I should be directed to another page where the
Sub-Category's children will be shown. But instead I have these errors:

NoMethodError in SubCategory#read
undefined method `each' for #<SubCategory:0x351c414>

  <div class="mH" onClick="toggleMenu('menu1')"><a href="#">+
24: <div id="menu1" class="mL">
25: <% @subcategory.each do |p| %>
26: <%= link_to, { :controller => "subsubcat", :action =>
"subsubcat_list", :id => } %>
27: <br/><% end %>
28: </div>

The following are my rhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"" >



<title>IGMON Webnav</title>

<%= javascript_include_tag :defaults %>

<%= stylesheet_link_tag "style", "scaffold" , "depot" , :media => "all"


<body id="category" >

<div id="banner" >

<img src="/images/logo.png" />

<%= @page_title || "Show Sub-Category" %>


<div id="columns" >

<div id="side" >

<td style="height: 500px; width: 140px;"> <a href="/profile">Profile


      <div class="mC">

      <div class="mH" onClick="toggleMenu('menu1')"><a href="#">+

<div id="menu1" class="mL">

<% @subcategory.each do |p| %>

<%= link_to, { :controller => "subsubcat", :action =>
"subsubcat_list", :id => } %>

<br/><% end %>




<div id="main" >

<% if flash[:notice] -%>

<div id="notice" ><%= flash[:notice] %></div>

<% end -%>

<%= yield :layout %>





<b><u>List of Sub-Categories</u></b><p>

<table border="1px">

<% @subcategory.each do |p| %>

<tr class="content">

<td style="width: 190px; height: 8px;colspan="1" rowspan="1"><%= link_to, { :action => "read", :id => } %></td>

<td style="width: 240px; height: 8px;colspan="1" rowspan="1"><%=
p.last_updated %></td>

<td style="width: 50px; height: 8px;colspan="1" rowspan="1"><%= link_to
"Copy", { :action => "copy", :id =>} %></td>

<td style="width: 50px; height: 8px;colspan="1" rowspan="1"><%= link_to
"Delete", { :action => "delete", :id =>}, {:post => true, :confirm
=> 'Are you sure you want to delete?'} %></td>

<td style="width: 70px; height: 8px;colspan="1" rowspan="1"><%= link_to
"Add pass", {:controller => "pass", :action => "pass", :id =>}


<% end %>



<%= button_to "Add Sub-Category", :action => :new, :id => :new %>

Does your error give you more information about which file (and which
line) is causing the error? My first impression is that you're not
setting the @subcategory (wouldn't @subcategories make more sense?)
instance variable for one of your two views. Also, it looks like
you're using @subcategory to hold the subcategories of your main
categories in categories.rhtml, but based on what you said about what
you expect to see in SubCategory.rhtml (unusual naming), you're using
the same variable (@subcategory) to hold the subcategories of the
subcategory. It's all pretty confusing...

See if you can extract more info about exactly where the error is
occurring. It's already telling you that @subcategory.each is a
problem, so narrow it down from there.