在Heroku上启用Ruby PostGIS支持
我正在尝试在Heroku上的Rails应用程序中启用PostGIS。 我的Gemfile
包含activerecord-postgis-adapter
gem:
gem 'activerecord-postgis-adapter', '3.0.0'
但是,在启动我的实例后,我没有看到启用完全支持:
$ heroku run irb Running `irb` attached to terminal... up, run.5549 irb(main):001:0> require 'rgeo' => true irb(main):002:0> RGeo::Geos.supported? => false
我已经添加了Postoku 文章中指定的heroku-geo-buildpack ,尽管我使用的是更新的,真正的multi-buildpack格式:
$ heroku buildpacks === staging Buildpack URLs 1. https://github.com/cyberdelia/heroku-geo-buildpack.git#1.3 2. https://github.com/heroku/heroku-buildpack-ruby.git#v140
我很困惑,因为我的构建过程看起来是正确的:
-----> Multipack app detected -----> Fetching custom git buildpack... done -----> geos/gdal/proj app detected Using geos version: 3.4.2 Using gdal version: 1.11.1 Using proj version: 4.8.0_1 -----> Vendoring geo libraries done -----> Fetching custom git buildpack... done -----> Ruby app detected -----> Compiling Ruby/Rails ...
我错过了什么? 我没有BUILDPACK_URL
环境变量集,因为我收集了旧的multi-buildpack方法。
PostGIS可以使用Heroku Free dyno和:
– Rails 4.2
– activerecord-postgis-adapter 3.1.4
你必须:
- 像这样设置你的config / database.yml:
default: &default adapter: postgis encoding: unicode # For details on connection pooling, see rails configuration guide # http://guides.rubyonrails.org/configuring.html#database-pooling pool: 5 development: <<: *default database: adopt_your_geek_development username: postgres host: mydb.com port: 9999 postgis_extension: postgis schema_search_path: public,postgis ... production: <<: *default database: appname_production username: appname password: <%= ENV['ADOPT_YOUR_GEEK_DATABASE_PASSWORD'] %> postgis_extension: postgis schema_search_path: public,postgis
- 添加buildpacks:
$ heroku buildpacks:add https://github.com/ddollar/heroku-buildpack-multi.git
使用以下.buildpacks文件:
$ cat .buildpacks https://github.com/cyberdelia/heroku-geo-buildpack.git https://github.com/heroku/heroku-buildpack-ruby.git
- 然后在config / environments / production.rb中添加一个小的monckey补丁
module ActiveRecord module ConnectionHandling class MergeAndResolveDefaultUrlConfig private def config @raw_config.dup.tap do |cfg| if url = ENV['DATABASE_URL'] cfg[@env] ||= {} cfg[@env]["url"] ||= url.try(:gsub, "postgres", "postgis") end end end end end end
我现在在Heroku免费dyno上为我工作,免费postgres。
我错过了Hobby层数据库不支持PostGIS的事实。
- 在windows上开发,在heroku上运行独角兽
- Heroku(PG ::错误:错误:列必须出现在GROUP BY子句中或用于聚合函数
- Ruby on Rails资产没有在Heroku上进行预编译
- 在heroku上的PostgreSQL数据库中存储超过255个字符
- 推送到Heroku失败:无法在任何来源中找到net-ssh-2.10.0。 无法通过Bundler安装gem
- ActionView :: Template :: Error(PG :: UndefinedFunction:ERROR:运算符不存在:整数~~未知
- 为Heroku静态编译pdftk。 需要将PDF拆分为单页文件
- Heroku帮助部署使用Mysql数据库的Rails应用程序
- 使用Carrierwave在Heroku上载大文件