Complement set association to has_many/through?

I have two models, A and B, with a straightforward many-to-many
has_many/through association between them. So, in A I have the
association processed_bs and in B I have processedby_as. This works

Now, I would like to also have an association unprocessed_bs in A,
which holds all Bs that aren’t in processed_bs. I can write a method
in A that returns all those objects as a list (using
B.find(:all,:conditions)), but that’s an assymetric and not very
pleasing solution. For example it means that I can to
aobj.processed_bs.count but not aobj.unprocessed_bs.count. Which is
clearly ugly.

I’ve tried playing around with feeding various variants of :select and
:finder_sql to the has_many declaration, but so far only produced lots
of different tracebacks. I’ve also got this ugly feeling that writing
that much SQL is an invitation to problems when/if I want to switch

So is there a neat way to get the complement set to an existing

Calle D. [email protected]
“Data on the network has cooties and will EAT YOUR BRAINS”
– Ross Younger, BofhNet

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs