Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logger bug #22

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/geokit-rails3/acts_as_mappable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ def acts_as_mappable(options = {})
if options.include?(:auto_geocode) && options[:auto_geocode]
# if the form auto_geocode=>true is used, let the defaults take over by suppling an empty hash
options[:auto_geocode] = {} if options[:auto_geocode] == true
cattr_accessor :auto_geocode_field, :auto_geocode_error_message
cattr_accessor :auto_geocode_field, :auto_geocode_error_message, :swallow_errors
self.auto_geocode_field = options[:auto_geocode][:field] || 'address'
self.auto_geocode_error_message = options[:auto_geocode][:error_message] || 'could not locate address'
self.swallow_errors = options[:auto_geocode][:swallow_errors] || false

# set the actual callback here
before_validation :auto_geocode_address, :on => :create
Expand Down Expand Up @@ -279,11 +280,15 @@ def flat_distance_sql(origin, units)
# this is the callback for auto_geocoding
def auto_geocode_address
address=self.send(auto_geocode_field).to_s
# don't try if the address is blank
return true if address.blank?
geo=Geokit::Geocoders::MultiGeocoder.geocode(address)

if geo.success
self.send("#{lat_column_name}=", geo.lat)
self.send("#{lng_column_name}=", geo.lng)
elsif swallow_errors
return true
else
errors.add(auto_geocode_field, auto_geocode_error_message)
end
Expand Down
6 changes: 3 additions & 3 deletions lib/geokit-rails3/geocoder_control.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
module Geokit
module GeocoderControl
extend ActiveSupport::Concern

included do
if self.respond_to? :before_filter
self.send :before_filter, :set_geokit_domain
end
end

def set_geokit_domain
Geokit::Geocoders::domain = request.domain
logger.debug("Geokit is using the domain: #{Geokit::Geocoders::domain}")
Geokit::Geocoders.logger.debug("Geokit is using the domain: #{Geokit::Geocoders::domain}")
end
end
end