Skip to content

Instantly share code, notes, and snippets.

@jwaldrip
Created September 14, 2012 21:06
Show Gist options
  • Save jwaldrip/3724821 to your computer and use it in GitHub Desktop.
Save jwaldrip/3724821 to your computer and use it in GitHub Desktop.
Fix Missing Medical Facility Categories
MedicalFacility.joins(:medical_facility_categories).where('medical_facility_categories.id !=4 AND physician_id IS NOT NULL').count
=> 45
MedicalFacility.joins(:medical_facility_categories).where('medical_facility_categories.id !=4 AND physician_id IS NOT NULL').each { |r| r.medical_facility_categories << MedicalFacilityCategory.find(4) }
MedicalFacility.joins(:medical_facility_categories).where('medical_facility_categories.id !=4 AND physician_id IS NOT NULL').count
=> 45
# Wtf?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment