27 lines
419 B
Ruby
27 lines
419 B
Ruby
class City < ActiveRecord::Base
|
|
|
|
|
|
def self.import
|
|
require 'csv'
|
|
@path = File.join(Rails.root, "new_cities.csv")
|
|
|
|
#Taxon.delete_all
|
|
CSV.foreach(@path, headers: true, :col_sep => ";" ) do |row|
|
|
|
|
attributes = {}
|
|
row.each do |r|
|
|
|
|
attributes[r[0].downcase.to_sym] = r[1].to_s
|
|
|
|
end
|
|
|
|
City.create(attributes)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|