Created
November 6, 2014 22:53
-
-
Save vykster/65d3db263a2131bfa99a to your computer and use it in GitHub Desktop.
copy mapper from Gavin
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
# Note this needs to be mapper_id, not import_file_id | |
MAPPER_TO_COPY = Mapper::Base.find(_ID_) | |
fipz = FipsCode.where(state: '_STATE_').where("county is not null").pluck(:id) | |
files = ImportFile::Voter.where(fips_code_id: fipz) | |
files.each do |file| | |
new_mapper = MAPPER_TO_COPY.copy | |
new_mapper.fips_code_id = file.fips_code_id | |
new_mapper.copied_from_mapper_id = nil | |
new_mapper.save | |
new_mapper.reload | |
file.mapper_id = new_mapper.id | |
file.save | |
end | |
# If you need to delete, cause you coppied the wrong mapper..... | |
files.each do |file| | |
m = file.mapper | |
m.destroy | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment