PostGIS: Using Geospatial Data with Rails
Last updated August 08, 2023
Table of Contents
CREATE EXTENSION postgis;
Setting Up PostGIS with Rails
To use PostgreSQL as your database in Ruby applications, include the
activerecord-postgis-adapter gem in your Gemfile.
To fully take advantage of PostGIS with Rails on Heroku, configure your app with a custom buildpack, which includes the appropriate system dependencies. This buildpack includes that support. Be sure to deploy the buildpack before building any gems.
To download and resolve all dependencies, run
bundle install. See the Ruby documentation for more information on getting set up with
After you’ve installed the gem, change the adapter to
postgis. See Rails Database Connection Behavior on how to modify your Rails connection adapter.