Only geocode addresses associated with enterprises. Makes Checkout#update much faster.

This commit is contained in:
Rohan Mitchell
2013-09-19 14:59:59 +10:00
parent 0183b0f2c1
commit 4956a4e384
2 changed files with 6 additions and 2 deletions

View File

@@ -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

View File

@@ -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