Thursday, April 7, 2011

Re: [Rails] How to display the list of children as links under their respective parent

On 7 April 2011 19:37, railer helper <railerhelper@gmail.com> wrote:
>                          <% @categories.each do |cat| %>
>                           <th>  <%=  link_to( cat.name, cat) %></th>
                        <% cat.products.each do |product| %>
>                         <tr><td> <%= link_to h(product.name), product %></td></tr>
<% end %>
>                         <% end %>

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.name), cat %>

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate