Sha256: 2de5ec4caa4c6252fa00c70bbfd6b74740f78a4cf9766811ed9bd8979bdd4692

Contents?: true

Size: 641 Bytes

Versions: 1

Compression:

Stored size: 641 Bytes

Contents

class Location < ActiveRecord::Base
  # Associations
  belongs_to :created_by, :class_name => 'User'
  belongs_to :updated_by, :class_name => 'User'

  acts_as_mappable :default_units => :kms
  before_validation :geocode_address
  
  default_scope :order => 'name'
  
  after_save :clear_page_cache
  private
  def geocode_address
    unless self.manual_geocode
      geo=GeoKit::Geocoders::MultiGeocoder.geocode self.full_address
      errors.add(:full_address, "Could not Geocode address") if !geo.success
      self.lat, self.lng = geo.lat,geo.lng if geo.success
    end
  end
  
  def clear_page_cache
    Radiant::Cache.clear
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
radiant-location-extension-1.2.1 app/models/location.rb