Limiting an :include

Hello,
I have image categories, and each category has an image. In my
controller I’m using:

@image_categories = ImageCategory.find(:all, :include => :images)

and inside the view

<% @image_categories.each do | category | -%>
<%= category.name %>
<% category.images.each do | image | -%>
<%= image.name%>
<% end -%>
<% end -%>

The code works, however i want to limit the display to only one image
per category. So my question would be how can i combine :limit with the
:include sintax ?

Thanks… any help would be really apreciated

You might want to look into has_one, in this case.

has_one :main_image, :class_name => “Image”

with a :conditions or :order or something specifying how to choose that
“main” image". It looks like you might not be using the has_many
relationship between Images and Categories correctly as well. I think
you
mean to have Category has_many :images and Category.find(:all, :include
=>
:images). ImageCategory looks a little Frankenmodel-y.

RSL