Skip to content

Instantly share code, notes, and snippets.

@nathancolgate
Created May 10, 2023 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathancolgate/ae79d63d976b5e2beefe41261cc749cf to your computer and use it in GitHub Desktop.
Save nathancolgate/ae79d63d976b5e2beefe41261cc749cf to your computer and use it in GitHub Desktop.
sheriff = Proprietor.find_by(name: "Sheriff")
Building.where(proprietor: sheriff).each do |building|
building.photo.purge
building.attachments.each do |attachment|
attachment.file.purge
end
building.floor_plans.each do |floor_plan|
floor_plan.blueprint.purge
end
building.building_systems.each do |system|
system.attachments.each do |attachment|
attachment.file.purge
end
end
building.deficiencies.each do |deficiency|
deficiency.attachments.each do |attachment|
attachment.file.purge
end
end
building.devices.each do |device|
device.attachments.each do |attachment|
attachment.file.purge
end
end
building.distress_samples.each do |sample|
sample.attachments.each do |attachment|
attachment.file.purge
end
end
building.report_archives.each do |archive|
archive.archived_reports.each do |report|
report.attachment.purge
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment