If you want to find all records in a which have no record in b....
A.find( :all, :include => :b, :conditions => ''b.id IS
NULL'' )
If you want to select a certain one, just add additional conditions as you
see fit.
mark
On 7/7/06, Ben Johnson <bjohnson@contuitive.com>
wrote:>
> Table A has many table B''s. So the foreign key in table B is a_id.
I want
> to select a single record from table A that does not have any table
B''s. The
> problem is that the foreign key is in table B. Is there a simple way to do
> this with the find method in active record? Or do I need to select all and
> loop through them all and check until I find one?
>
> Thanks for your help.
>
>
> Thank You,
> Ben Johnson
>
>
>
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>
--
Mark Van Holstyn
mvette13@gmail.com
http://lotswholetime.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060707/e1faed67/attachment.html