This seems fairly simple but I can't get it to turn up on Google.
If I have:
class City < ActiveRecord::Base
has_many :photos
end
class Photo < ActiveRecord::Base
belongs_to :city
end
City.where( photos.empty? )
scope :without_photos, includes(:photos).where( :photos => {:city_id=>nil} )
scope :with_photos, ???
Bah, found it here: http://stackoverflow.com/a/5570221/417872
City.includes(:photos).where(photos: { city_id: nil })