diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 97a298b766..c4d18eb414 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -23,6 +23,7 @@ class Enterprise < ActiveRecord::Base after_initialize :initialize_country before_validation :set_unused_address_fields + after_validation :geocode_address scope :by_name, order('name') scope :is_primary_producer, where(:is_primary_producer => true) @@ -114,4 +115,8 @@ class Enterprise < ActiveRecord::Base def set_unused_address_fields address.firstname = address.lastname = address.phone = 'unused' if address.present? end + + def geocode_address + address.geocode if address.changed? + end end diff --git a/app/models/spree/address_decorator.rb b/app/models/spree/address_decorator.rb index ead4e36c35..7cfd6cca0b 100644 --- a/app/models/spree/address_decorator.rb +++ b/app/models/spree/address_decorator.rb @@ -2,7 +2,6 @@ Spree::Address.class_eval do has_one :enterprise geocoded_by :full_address - after_validation :geocode delegate :name, :to => :state, :prefix => true, :allow_nil => true @@ -19,7 +18,7 @@ Spree::Address.class_eval do # their way into the database. I don't know what the source of them is, so this patch # is designed to track them down. # This is intended to be a temporary investigative measure, and should be removed from the - # code base shortly. + # code base shortly. If it's past 17-10-2013, take it out. # #-- Rohan, 17-9-2913 def create