Last active
February 19, 2016 15:33
-
-
Save dvjones89/4560720d37a43f0d287f 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
# For example, | |
# mappings = [["actualgeek","david.jones@freeagent.com"]] | |
ap = AccountancyPractice.find xxxx | |
mappings.each do |map| | |
subdomain = map[0] | |
email = map[1] | |
company = ap.companies.find_by_subdomain(subdomain) | |
old_manager = company.account_manager | |
new_manager = ap.account_managers.find_by_email(email) | |
if old_manager != new_manager | |
puts "Changing company #{company.subdomain}(#{company.id}) from AccountManager##{old_manager.id} to AccountManager##{new_manager.id}" | |
company.account_manager = new_manager | |
company.save! | |
else | |
puts "Skipping company #{company.subdomain}(#{company.id}) as account manager is already correct" | |
end | |
end;nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment