Hello, I need help on a this problem: I have a "Categories / Items" database in a "has_many - belongs_to" relationship On the "Items" page I want to display the items grouped by Category, so in the controller I have: class ItemController < ApplicationController ... def list @categories = Category.find(:all, :order => "description") @items = Item.find(:all, :order => "description") end ... in the Items "list" view, I have: <%# cycles though the categories %> <%= render :partial => "category", :collection => @categories } %> The "_category.rhtml" partial is: <%= category.description %> <%# I have to populate the @items collection here, by category %> <% @items = Items.find( :all, :conditions => ["category_id LIKE ?" , category.id] ) %> <% # and render the items lines for the category # the "_item.rhtml" partial contains the data for the item row %> <%= render :partial => "item", :collection => @items %> I would like to do this WITHOUT populating the "@items" collection inside the view, and moving all the data operations in the controller if possible. Someone got any ideas for "refactoring" this? Thank you in advance. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---