Created
January 12, 2013 02:28
-
-
Save thomasbiddle/4515739 to your computer and use it in GitHub Desktop.
if model Foo has_many model Bars how can I find Foos that don't have any Bars at all?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Foo.all.each do |f| | |
if Bar.where(:foo_id => f.id).all.empty? | |
puts "#{f.id} has no bars!" | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment