gem 'activerecord-postgis-adapter'
bundle install
# database.yml
development:
adapter: postgis
encoding: unicode
postgis_extension: postgis # default is postgis
postgis_schema: public # default is public
schema_search_path: public,postgis
pool: 5
database: my_app_development # your database name
username: my_app_user # the username your app will use to connect
password: my_app_password # the user's password
su_username: my_global_user # a superuser for the database
su_password: my_global_pasword # the superuser's password
sudo apt-get install postgresql-9.5-postgis-scripts
sudo apt-get install postgresql-9.5-postgis-2.2
rake db:gis:setup
Add a point attribute to table
class AddLatlongToLocations < ActiveRecord::Migration[5.0]
def change
add_column :locations, :latlong, :st_point
end
end
Make a point instance in code
l.latlong = "POINT(3 4)"
l.latlong = RGeo::Cartesian::Factory.new.point(2,2)