lib/earth/locality/zip_code.rb in earth-0.12.3 vs lib/earth/locality/zip_code.rb in earth-0.12.4
- old
+ new
@@ -1,14 +1,22 @@
require ::File.join(Earth::VENDOR_DIR, 'geokit-rails', 'lib', 'geokit-rails') # for acts_as_mappable
class ZipCode < ActiveRecord::Base
self.primary_key = "name"
- belongs_to :egrid_subregion, :foreign_key => 'egrid_subregion_abbreviation'
belongs_to :climate_division, :foreign_key => 'climate_division_name'
belongs_to :state, :foreign_key => 'state_postal_abbreviation'
+ belongs_to :egrid_subregion, :foreign_key => 'egrid_subregion_abbreviation'
has_many :electric_markets, :foreign_key => 'zip_code_name'
has_many :electric_utilities, :through => :electric_markets
+
+ scope :known_subregion, where('egrid_subregion_abbreviation IS NOT NULL')
+
+ data_miner do
+ process "Ensure Country is imported because it's like a belongs_to association" do
+ Country.run_data_miner!
+ end
+ end
def country
Country.united_states
end