Sha256: 0f252edab466591c93a6add1f7205959fd824a568293512bacc5a5d2aaa9b58d

Contents?: true

Size: 516 Bytes

Versions: 17

Compression:

Stored size: 516 Bytes

Contents

module Apidae
  class Town < ActiveRecord::Base
    def self.import(json_file)
      result = true
      towns_json = File.read(json_file)
      towns_hashes = JSON.parse(towns_json, symbolize_names: true)
      towns_hashes.each do |town_data|
        Town.create!(name: town_data[:nom], postal_code: town_data[:codePostal], insee_code: town_data[:code],
                     country: 'fr', apidae_id: town_data[:id])
      end
      result
    end

    def label
      "#{name} (#{postal_code})"
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
apidae-0.2.8 app/models/apidae/town.rb
apidae-0.2.7 app/models/apidae/town.rb
apidae-0.2.6 app/models/apidae/town.rb
apidae-0.2.5 app/models/apidae/town.rb
apidae-0.2.4 app/models/apidae/town.rb
apidae-0.1.6 app/models/apidae/town.rb
apidae-0.1.5 app/models/apidae/town.rb
apidae-0.2.3 app/models/apidae/town.rb
apidae-0.2.2 app/models/apidae/town.rb
apidae-0.2.1 app/models/apidae/town.rb
apidae-0.2.0 app/models/apidae/town.rb
apidae-0.1.4 app/models/apidae/town.rb
apidae-0.1.3 app/models/apidae/town.rb
apidae-0.1.2 app/models/apidae/town.rb
apidae-0.1.1 app/models/apidae/town.rb
apidae-0.1.0 app/models/apidae/town.rb
apidae-engine-rails-0.1.0 app/models/apidae/town.rb