How can I find(:all) on a parent model only for objects where a has_one
child is nil?
Models
---
class Parent < ActiveRecord::Base
has_one :child
end
class Child < ActiveRecord::Base
belongs_to :parent
end
So, I want to do:
object = Parent.find(:all) where the only rows returned match
object.child.nil?
I want this to happen on the database level because we will be dealing with
thousands of rows. Is there an ActiveRecord way to handle this, or am I
going to have to break out to find_by_sql for this?
Ryan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---