Forum: Ruby on Rails Complement set association to has_many/through?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Calle D. (Guest)
on 2006-05-04 20:08
(Received via mailing list)
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. <removed_email_address@domain.invalid>
	  "Data on the network has cooties and will EAT YOUR BRAINS"
			   -- Ross Younger, BofhNet
This topic is locked and can not be replied to.