Displaying 1 result from an estimated 1 matches for "all_ivrs".
Did you mean:
all_ids
2008 Apr 24
2
Dynamic finders in has_many associations
...:ivr
end
I faced 2 problems and didn''t manage to find any good tutorial.
1. Given some Kluster A, I want to find all the Ivrs that aren''t in A.
2. I want to find all the Ivrs that aren''t in ANY Kluster.
-- I managed to do 1. with:
@kluster = Kluster.find(params[:id])
@all_ivrs = Ivr.find(:all)
@ivrs = (@all_ivrs - @kluster.ivrs)
-- And I did 2. with:
@all_ivrs = Ivr.find(:all).select{ |ivr| ivr.klusters.empty? }
But 1. does two SQL queries, one possibly very big (Ivr.find(:all)).
And 2. does that too.
Any way to do this, preferibly with dynamic finders?
--~--~-------...