Skip to content

Instantly share code, notes, and snippets.

@arockwell
Created May 16, 2012 19:05
Show Gist options
  • Select an option

  • Save arockwell/2713095 to your computer and use it in GitHub Desktop.

Select an option

Save arockwell/2713095 to your computer and use it in GitHub Desktop.
merge_users
User.reflect_on_all_associations.each do |assoc|
puts "Processing class: #{assoc.klass}"
collection = merge_in_user.send(assoc.name)
user.send(assoc.name) = user.send(assoc.name) + collection
user.save
merge_in_user.send(assoc.name).clear
end
merge_in_user.delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment