【问题标题】:Postgis is not setting up in Rails applicationPostgis 未在 Rails 应用程序中设置
【发布时间】:2020-06-17 18:48:18
【问题描述】:

我正在将 PostGIS 集成到 Rails 应用程序中,并遵循他们的文档https://github.com/rgeo/activerecord-postgis-adapter

到这一步

rake db:create

我收到以下错误。

ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: 在“SUPPORT”处或附近出现语法错误 : 如果不存在带有 SCHEMA public 的 postgis,则创建扩展

我的数据库.yml

default: &default
  adapter: postgresql
  encoding: unicode
  # For details on connection pooling, see Rails configuration guide
  # http://guides.rubyonrails.org/configuring.html#database-pooling
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  adapter: postgis
  encoding: unicode
  postgis_extension: postgis      # default is postgis
  postgis_schema: public          # default is public
  schema_search_path: public,postgis
  pool: 5
  database: my_app_development    # your database name


test:
  <<: *default
  database: my_app_test

production:
  <<: *default
  database: my_app_production
  username: my_app
  password: <%= ENV['MY_APP_DATABASE_PASSWORD'] %>

【问题讨论】:

    标签: ruby-on-rails activerecord postgis rgeo


    【解决方案1】:

    只需删除所有您不需要的选项database.yml

    default: &default
      adapter: postgis
      encoding: unicode
      pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
    
    development:
      <<: *default
      database: my_app_development    # your database name
    
    test:
      <<: *default
      database: my_app_test
    
    production:
      <<: *default
      database: my_app_production
      username: my_app
      password: <%= ENV['MY_APP_DATABASE_PASSWORD'] %>
    

    【讨论】:

      猜你喜欢
      • 2012-07-28
      • 2011-02-23
      • 1970-01-01
      • 2020-02-28
      • 1970-01-01
      • 2015-05-19
      • 2012-11-15
      • 1970-01-01
      • 2013-12-17
      相关资源
      最近更新 更多