Maarten,
On Fri, Apr 14, 2006 at 01:30:51PM +0200, Maarten Hendrikx wrote:
> I want to display a list of links grouped by category like this:
> Group 1
> Link 1
> Link 2
> Group 2
> Link 1
> Link 2
What a coinsidence. I just set up a similar link section yesterday.
> Can somebody give my some pointers how to achieve this? Thanks!
I''m very new to Rails so there it is very likely that there is a better
way
to do this. But, the way I did it was:
In my Link controller:
def list
@categories = LinkCategory.find(:all, :order =>
''name'')
end
And in my list.rhtml view something along the lines of:
<% for category in @categories -%>
<h2><%= h(category.name) %></h2>
<% for link in category.links -%>
<p><%= link_to h(link.name), link.url %></p>
<% end -%>
<% end -%>
Kevin
http://www.RawFedDogs.net
http://www.WacoAgilityGroup.org
Bruceville, TX