Martin DeMello
7/14/2008 9:47:00 PM
On Mon, Jul 14, 2008 at 2:37 PM, Nate Leavitt <nateleavitt@gmail.com> wrote:
>>>
>>> @invoices.each do |invoice|
>>> if invoice[:id] == params[:contact_id]
>>> bla... bla...
>>> end
>
> Thanks for the reply. Yes, I am working in rails :) It just seems
> kinda tedious to keep iterating over all these collections. Just
> wondering if there is a more efficient way.
Where did @invoices come from in the first place? If it came from the
database, you are probably doing things in your loop that you should
be doing in the sql query (e.g. Invoice.find(params[:contact_id])
rather than your if guard in the loop)
martin