Created
May 30, 2013 16:52
-
-
Save stevebooks/5679398 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Fix certificates that have a duplicate name | |
#Captable.where(id: 990).find_each do |cap| | |
Captable.find_each do |cap| | |
results = {} | |
cap.equity_certificates.find_each do |s| | |
puts "Cert ID: #{s.id}" | |
name = s.name.strip | |
if results.has_key?(name) | |
results[name] << s | |
else | |
results[name] = [s] | |
end | |
end | |
#remove any items that only have one item in the array (which means it is not a duplicate) | |
results = results.delete_if{|k,v| v.size == 1} | |
ap results | |
results.each do |k,v| | |
v.shift | |
v.each do |dup| | |
dup.save! | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment