20. # config/database.yml
adapter: postgis
# When postgresql >= 9.1 and postgis >= 2.0
postgis_extension: true
# When postgresql < 9.1 or postgis < 2.0
# e.g. for postgresql 9.1 and postgis 1.5 on ubuntu
script_dir: "/usr/share/postgresql/9.1/contrib/postgis-1.5"
schema_search_path: public,postgis
21. create_table :locations do |t|
t.point :coords, geographic: true
end
create_table :locations do |t|
t.string :text
t.point :coords, srid: 3785
end
add_index :locations, :coords, spatial: true
22. class Location < ActiveRecord::Base
GEOFACTORY =
RGeo::Geographic.spherical_factory(srid: 4326)
set_rgeo_factory_for_column :coords, GEOFACTORY
end