Re: Finding all records that don't have child

That is finding all B records that have no parent. I want to find all A
records that have no child…

I’m thinking that the best/fastest way to do this would to just use
counters.

You wrote:

I would use a named_scope in this instance, assuming the relationship
fields are completely normal.

So the field that u want to check is the association id is nil.

an example for that would be like this:

named_scope :unassociated, :conditions => “foreignkey_id IS NULL”

hope that works…

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