Table of Contents [expand]
PostGIS is available on all Heroku Postgres plans and currently supports PostGIS versions 2.5 and 3.3. To enable PostGIS after connecting to your PostgreSQL database, run:
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 classic buildpack for Cedar-generation apps include that support. For now, there is no Cloud Native Buildpack-equivalent for Fir-generation apps.
Be sure to deploy the buildpack before building any gems.
gem 'activerecord-postgis-adapter'
To download and resolve all dependencies, run bundle install
. See the Ruby documentation for more information on getting set up with activerecord-postgis-adapter
.
After you’ve installed the gem, change the adapter to postgis
. See Rails Database Connection Behavior on how to modify your Rails connection adapter.