Franz Strebel wrote: > On Tue, Sep 16, 2008 at 3:55 PM, surge <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > > Sorry if this has been asked before... > > I have a model named ticket (like a trouble ticket) and a ticket can > have many issues. When I list tickets in a table I want to output the > number of issues each ticket has. So, in my view I do something like: > > <%= ticket.issues.count %> > > > You should use eager loading to include the issues when you get the > tickets, à la > > @tickets = Ticket.find(:all, :include => :issues) > > > Or use a counter cache if all you need is the number. > > >
-- Jack Christensen [EMAIL PROTECTED] --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

