There is a solution:
First of all, you will need a PostgreSQL template with support for PostGIS functions.
Create a template database:
$ psql -U postgres > CREATE DATABASE template_postgis WITH TEMPLATE=template1 ENCODING='UTF8'; > \c template_postgis; > CREATE LANGUAGE plpgsql;
Download the necessary PostGIS functions to the template (I use Homebrew, so find the paths to your PostGIS SQL files):
$ psql -f /usr/local/share/postgis/postgis.sql template_postgis $ psql -f /usr/local/share/postgis/spatial_ref_sys.sql template_postgis
Set the database as a template and grant permissions:
$ psql -U postgres template_postgis > UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis'; > GRANT ALL ON geometry_columns TO PUBLIC; > GRANT ALL ON spatial_ref_sys TO PUBLIC;
Then add the gem 'postgis_adapter' to your Gemfile and run bundle . After that, add template: template_postgis to your config/database.yml as follows:
development: adapter: postgresql template: template_postgis database: postgis_db
And - voila! Welcome aboard!
source share