How to display the list of children as links under their respective parent

Hey…Does nybody know how to display a list(array) as links Eg: I’ve a @products and @categories enumerable objects supplied to the view from a single CategoryController … I want to show the products under their respective categories as links and get rid of the separate show page for displaying products list…

I was able to get the categories links working as expected… but products name appear simply as plain text… <% @categories.each do |cat| %> <%= link_to(, cat) %>

                  <tr><td> <%= cat.products.collect {

c> } %> ####-----I need links Here!!! <% end %>
…But if I put link_to inside the cat.products.collect { |c| link_to , c }, I get the html escaped text for links inside the[…]

Category and Product models have has_many_through relationship…

How to go about this…???

                     &lt;% @categories\.each do |cat| %&gt;
                       &lt;th&gt;  &lt;%=  link\_to\( cat\.name, cat\) %&gt;&lt;/th&gt;
                            &lt;% cat\.products\.each do |product| %&gt;
                           &lt;tr&gt;&lt;td&gt; &lt;%= link\_to h\(product\.name\), product %&gt;&lt;/td&gt;&lt;/tr&gt;

                                <% end %>

                     &lt;% end %&gt;

Since it's a list of a category's products, it would be more semantic to use a <ul> element rather than lots of rows in the table though. Oh, and BTW - you'll want to html escape the category name too...   <%= link_to h(, cat %>

Thanks for the suggestion man…It works exactly as i wanted…I din’t know we can have a block inside another block!!!