【问题标题】:Can't get PostGIS to work with Heroku / Rails - NoMethodError: undefined method `geography' / 'st_point'无法让 PostGIS 与 Heroku / Rails 一起使用 - NoMethodError: undefined method `geography' / 'st_point'
【发布时间】:2017-02-24 09:10:09
【问题描述】:

我在尝试使用 Rails 5.0.1 在 Heroku 上迁移或 db:schema:load 时遇到这些错误

宝石文件

# PostGIS adapter
gem 'activerecord-postgis-adapter'

数据库.yml

default: &default
  adapter: postgis
  encoding: unicode
  pool: 5
  postgis_extension: postgis
  schema_search_path: public, postgis
production:
  <<: *default
  database: appname_production
  username: appname
  password: <%= ENV['APPNAME_DATABASE_PASSWORD'] %>

迁移

t.st_point :location, geographic: true, null: false

schema.rb

t.geography "location", limit: {:srid=>4326, :type=>"point", :geographic=>true}, null: false

构建包

$ heroku buildpacks
=== appname-staging Buildpack URLs
1. https://github.com/cyberdelia/heroku-geo-buildpack.git
2. heroku/ruby

运行heroku run rake db:migrateheroku run rake db:schema:load 分别给出NoMethodError: undefined method `st_point'NoMethodError: undefined method `geography'。我怎样才能解决这个问题?我错过了什么?

【问题讨论】:

  • @你最后是怎么解决这个问题的?
  • 你解决了这个问题吗?

标签: ruby-on-rails ruby heroku postgis


【解决方案1】:

在这种情况下,这将帮助我管理的人通过使用解决问题

  production:
    <<: *default
    url: <%= ENV.fetch('DATABASE_URL', '').sub(/^postgres/, "postgis") %>
    database: databasename_production
    username: databasename
    password: <%= ENV['databasename_DATABASE_PASSWORD'] %>

在我的 database.yml 文件中

【讨论】:

  • 谢谢,你太棒了!
【解决方案2】:

【讨论】:

    猜你喜欢
    • 2020-09-24
    • 1970-01-01
    • 2022-11-20
    • 2011-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多