lib/tasks/fix_maine_nil_counties.rake
# - find families missing county
# - update county for single county
# - list the county with nil county with zip outside ME
# - application county update
find families missing county
update county for single county
list the county with nil county with zip outside ME
application county update
find families missing county update county for single county list the county with nil county with zip outside ME application county update
def address_fixer(address)
      zip = address.zip.match(/^(\d+)/).captures.first 
      town_name = address.city.titleize
      county_name = find_specific_county(town_name)
      counties = county_finder(zip)
      if counties.count == 1
        address.county = counties.first.county_name
        address.save!
        :fixed
      elsif county_name.present?
        address.county = county_name
        address.save!
        puts("Successfully resolved county by town for #{town_name}")
        :fixed
      elsif counties.count == 0
        puts "No county found for ZIP: #{zip} #{address.state}"
        :no_county_found
      else
        puts "Unable to resolve multiple counties found for ZIP: #{zip} #{address.state}"
        :multiple_counties_found
      end
    end
def address_fixer ( address ) zip = address . zip . match ( / ^( \d +) / ) . captures . first town_name = address . city . titleize county_name = find_specific_county ( town_name ) counties = county_finder ( zip ) if counties . count == 1 address . county = counties . first . county_name address . save! :fixed elsif county_name . present? address . county = county_name address . save! puts ( "Successfully resolved county by town for #{town_name}" ) :fixed elsif counties . count == 0 puts "No county found for ZIP: #{zip} #{address.state}" :no_county_found else puts "Unable to resolve multiple counties found for ZIP: #{zip} #{address.state}" :multiple_counties_found end end
find families missing county
 update county for single county
 list the county with nil county with zip outside ME
 application county update
find families missing county update county for single county list the county with nil county with zip outside ME application county update
# incase of 20640-2342 (9 digit zip) # Must be titleized like "Presque Isle" or "Bangor"
address