Rails Dispatch

Rails news delivered fresh

Presented by Engine Yard

View Question

Vote on questions you’d like to see answered by the expert contributors

Signup to ask questions or vote for the questions you’d like to see answered.

Displaying 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.name, cat) >
<
= cat.products.collect { |c| c.name } > ####<<< end %>
…But if I put link_to inside the cat.products.collect { |c| link_to c.name, 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……??????

Asked April 07, 2011