Skip to content

Instantly share code, notes, and snippets.

@djvs
Created March 13, 2015 16:57
Show Gist options
  • Save djvs/bba66fa68a425e281ef4 to your computer and use it in GitHub Desktop.
Save djvs/bba66fa68a425e281ef4 to your computer and use it in GitHub Desktop.
# fix routes - this should only run once
Course.all.each_with_index do |c,ind|
fixhash = c.routes.map{|x| {x.originalid => x.id}}.reduce(:merge) || {}
routes = c.routes
routes.each do |r|
r.ancestors = r.ancestors.map{|x| (fixhash[x] == nil) ? (x.to_s.length < 22 ? x : nil ) : fixhash[x]}.compact
r.save
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment