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

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

The following are my rhtml


IGMON Webnav

<%= javascript_include_tag :defaults %>

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

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

Profile Manager

  <div class="mC">

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


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

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

<% end %>



<% if flash[:notice] -%>

<%= flash[:notice] %>

<% end -%>

<%= yield :layout %>


List of Sub-Categories

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

<% end %>

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


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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs