Geokit::ActsAsMappable

Contains the class method acts_as_mappable targeted to be mixed into ActiveRecord. When mixed in, augments find services such that they provide distance calculation query services. The find method accepts additional options:

Other finder methods are provided for specific queries. These are:

Counter methods are available and work similarly to finders.

If raw SQL is desired, the distance_sql method can be used to obtain SQL appropriate to use in a find_by_sql call.

Public Class Methods

end_of_reflection_chain(through, klass) click to toggle source

(Not documented)

     # File /Users/andre/projects/rails/geokit_dev/vendor/plugins/geokit/lib/geokit-rails/acts_as_mappable.rb, line 112
112:     def self.end_of_reflection_chain(through, klass)
113:       while through
114:         reflection = nil
115:         if through.is_a?(Hash)
116:           association, through = through.to_a.first
117:         else
118:           association, through = through, nil
119:         end
120: 
121:         if reflection = klass.reflect_on_association(association)
122:           klass = reflection.klass
123:         else
124:           raise ArgumentError, "You gave #{association} in :through, but I could not find it on #{klass}."
125:         end
126:       end
127: 
128:       reflection
129:     end

Public Instance Methods

auto_geocode_address() click to toggle source

this is the callback for auto_geocoding

     # File /Users/andre/projects/rails/geokit_dev/vendor/plugins/geokit/lib/geokit-rails/acts_as_mappable.rb, line 98
 98:     def auto_geocode_address
 99:       address=self.send(auto_geocode_field).to_s
100:       geo=Geokit::Geocoders::MultiGeocoder.geocode(address)
101: 
102:       if geo.success
103:         self.send("#{lat_column_name}=", geo.lat)
104:         self.send("#{lng_column_name}=", geo.lng)
105:       else
106:         errors.add(auto_geocode_field, auto_geocode_error_message) 
107:       end
108: 
109:       geo.success
110:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.