Navigation Problems

Hi,

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?
Thanks

In the navigation bar, I have the following links:

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

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

+ AMD
23: 24:
25: <% @subcategory.each do |p| %> 26: <%= link_to p.name, { :controller => "subsubcat", :action => "subsubcat_list", :id => p.id } %> 27:
<% end %> 28:

The following are my rhtml

…app/views/layout/categories.rhtml…

IGMON Webnav

<%= javascript_include_tag :defaults %>

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

<%= @page_title || “Show Sub-Category” %>

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

<%= link_to p.name, { :controller => “subsubcat”, :action =>
“subsubcat_list”, :id => p.id } %>


<% end %>

</div>




  </div>

<% if flash[:notice] -%>

<%= flash[:notice] %>

<% end -%>

<%= yield :layout %>

…app/views/…/SubCategory.rhtml…

List of Sub-Categories

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

<% end %>

<%= link_to p.name, { :action => "read", :id => p.id } %> <%= p.last_updated %> <%= link_to "Copy", { :action => "copy", :id => p.id} %> <%= link_to "Delete", { :action => "delete", :id => p.id}, {:post => true, :confirm => 'Are you sure you want to delete?'} %> <%= link_to "Add pass", {:controller => "pass", :action => "pass", :id => p.id} %>

<%= 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.

-Kyle

On Mar 31, 9:58 pm, user splash [email protected]