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>
<div class="mH" onClick="toggleMenu('menu1')"><a href="#">+ AMD</a></div> 23: 24: <div id="menu1" class="mL"> 25: <% @subcategory.each do |p| %> 26: <%= link_to p.name, { :controller => "subsubcat", :action => "subsubcat_list", :id => p.id } %> 27: <br/><% end %> 28: </div>
The following are my rhtml
.....................app/views/layout/categories.rhtml......................
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<html>
<head>
<title>IGMON Webnav</title>
<%= javascript_include_tag :defaults %>
<%= stylesheet_link_tag "style", "scaffold" , "depot" , :media => "all" %>
</head>
<body id="category" >
<div id="banner" >
<img src="/images/logo.png" />
<%= @page_title || "Show Sub-Category" %>
</div>
<div id="columns" >
<div id="side" >
<td style="height: 500px; width: 140px;"> <a href="/profile">Profile Manager<br>
</a>
<div class="mC">
<div class="mH" onClick="toggleMenu('menu1')"><a href="#">+ AMD</a></div>
<div id="menu1" class="mL">
<% @subcategory.each do |p| %>
<%= link_to p.name, { :controller => "subsubcat", :action => "subsubcat_list", :id => p.id } %>
<br/><% end %>
</div>
</div>
</div>
<div id="main" >
<% if flash[:notice] -%>
<div id="notice" ><%= flash[:notice] %></div>
<% end -%>
<%= yield :layout %>
</div>
</div>
</body>
</html>
.....................app/views/.../SubCategory.rhtml....................
<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 p.name, { :action => "read", :id => p.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 => p.id} %></td>
<td style="width: 50px; height: 8px;colspan="1" rowspan="1"><%= link_to "Delete", { :action => "delete", :id => p.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 => p.id} %><br/></td>
</tr>
<% end %>
</table>
<br/>
<%= button_to "Add Sub-Category", :action => :new, :id => :new %>