19 lines
706 B
Ruby
19 lines
706 B
Ruby
module JamRuby
|
|
class GeoIpLocations < ActiveRecord::Base
|
|
|
|
self.table_name = 'geoiplocations'
|
|
|
|
def self.lookup(locid)
|
|
GeoIpLocations.where(locid: locid)
|
|
.limit(1)
|
|
.first
|
|
end
|
|
|
|
def self.createx(locid, countrycode, region, city, postalcode, latitude, longitude, metrocode, areacode)
|
|
c = connection.raw_connection
|
|
c.exec_params('insert into geoiplocations (locid, countrycode, region, city, postalcode, latitude, longitude, metrocode, areacode, geog) values($1, $2, $3, $4, $5, $6, $7, $8, $9, ST_SetSRID(ST_MakePoint($7, $6), 4326)::geography)',
|
|
[locid, countrycode, region, city, postalcode, latitude, longitude, metrocode, areacode])
|
|
end
|
|
end
|
|
end
|