Permalink
Browse files

Enable deleting dubious parents

  • Loading branch information...
1 parent 4dc4242 commit e0ea5d10649e56d15ab82685a87e1b3111be26a7 @cthielen cthielen committed Feb 27, 2014
Showing with 6 additions and 5 deletions.
  1. +1 −1 config/initializers/last_updated.rb
  2. +5 −4 lib/tasks/organization_tasks.rake
@@ -1 +1 @@
-LAST_UPDATED = 'Wed Feb 26 17:13:21 PST 2014'
+LAST_UPDATED = 'Wed Feb 26 17:16:44 PST 2014'
@@ -264,8 +264,6 @@ namespace :organization do
remove = args[:options] == 'remove'
- puts "Remove is #{remove}"
-
Organization.all.each do |organization|
if organization.parent_organizations.length > 1
parent_ids = organization.parent_organizations.map{ |org| org.id }
@@ -274,8 +272,11 @@ namespace :organization do
intersections = parent_ids & grandparent_ids
intersections.each do |i|
- puts "#{organization.name} (#{organization.id}) has #{Organization.find_by_id(i).name} (#{Organization.find_by_id(i).id}) as a parent but this is also a grandparent. Removing ..."
- #organization.parent_organizations.destroy(Organization.find_by_id(i))
+ puts "#{organization.name} (#{organization.id}) has #{Organization.find_by_id(i).name} (#{Organization.find_by_id(i).id}) as a parent but this is also a grandparent."
+ if remove
+ puts "Removing ..."
+ organization.parent_organizations.destroy(Organization.find_by_id(i))
+ end
puts "Other parents:"
parent_ids.each do |p|
puts "\t#{Organization.find_by_id(p).name} (#{Organization.find_by_id(p).id})" unless intersections.include? p

0 comments on commit e0ea5d1

Please sign in to comment.