2009/9/17 Greg Donald <[email protected]>: > > On Wed, Sep 16, 2009 at 7:33 PM, Dudebot <[email protected]> wrote: >> >> Thanks super, Greg, for helping me out. I'm dense, 'cause I couldn't >> figure out the syntax for 'whatever'. I did get this to work in >> the .erb file: >> >> <% if Item.find( item ).orders.size > 0 %> > > I'd go with orders.empty? > > You will want to do your find in the controller. Set the results to > an instance variable. > > @item = Item.find(...) > > Then that instance variable is available in your view: > > <%= debug @item %> > >> <%=h "Found #{item.title} in Orders" %> >> <% end %> >> >> But I'm just wondering... is that the most efficient way to do it? Is >> there a more efficient way? > > Depends on your app. You might want that :include => :items or you > might not. It'll save a bunch of smaller queries later if you leave > it off, but then what if you needed all those items? It's up to you.
Isn't that the wrong way round? Colin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

