[postgis-users] calling tiger geocoder functions from rails?
Jeff Rossi
rossi.jeff at gmail.com
Wed May 23 05:45:08 PDT 2012
I got it working
installed the pg, georuby, and spatial_adapter gems
# in app/models/
class PostgisGeocoder < ActiveRecord::Base
establish_connection "postgis_geocoder_#{Rails.env}"
def self.normalize_address(address_string)
query = "SELECT (addy).address As stno, (addy).streetname As street,
(addy).streettypeabbrev As styp, (addy).location As city, (addy).stateabbrev
As st,(addy).zip FROM normalize_address('#{address_string}') as addy;"
norm_addy = self.connection.execute(query)
norm_addy[0]
end
end
# in database.yml
postgis_geocoder_development:
adapter: postgresql
database: geocoder
username: postgres
password: *********
Hope that can help .
--
View this message in context: http://postgis.17.n6.nabble.com/calling-tiger-geocoder-functions-from-rails-tp4997646p4997700.html
Sent from the PostGIS - User mailing list archive at Nabble.com.
More information about the postgis-users
mailing list