# Navigation Problems

**URL:** <https://www.ruby-forum.com/t/navigation-problems/133502>\
**Category:** Rails\
**Created:** [April 1, 2008, 4:58am UTC](https://www.ruby-forum.com/t/navigation-problems/133502 "2008-04-01T04:58:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [April 1, 2008, 4:58am UTC](https://www.ruby-forum.com/t/navigation-problems/133502/1 "2008-04-01T04:58:57Z")

</div>

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”  
%\>

![](https://www.ruby-forum.com/images/logo.png)

\<%= @page\_title || “Show Sub-Category” %\>

[Profile Manager  
 

```
  </a>

  <div class="mC">

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

```

 ](https://www.ruby-forum.com/profile)

[AMD](https://www.ruby-forum.com/profile)

\<% @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 %\>

---

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [April 1, 2008, 5:13pm UTC](https://www.ruby-forum.com/t/navigation-problems/133502/2 "2008-04-01T17:13:01Z")

</div>

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 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
