0

我已经成功安装了 PostGIS 并使用postgres_extgem 添加了支持 Rails postgisActiveRecord 适配器,但是当我尝试在迁移中使用 Postgres 数组列类型时,它失败了:

t.string :pets, :array => true, :limit => 12

和错误:

rake aborted!
An error has occurred, this and all later migrations canceled:

    undefined method `array' for #<ActiveRecord::ConnectionAdapters::ColumnDefinition:0x007fa8357b3308>
    /Users/avishai/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/core_ext/object/try.rb:36:in `try'
    /Users/avishai/.rvm/gems/ruby-1.9.3-p194/gems/postgres_ext-0.0.9/lib/postgres_ext/active_record/connection_adapters/postgres_adapter.rb:197:in `add_column_options!'
    /Users/avishai/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/schema_definitions.rb:38:in `add_column_options!'
    /Users/avishai/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/schema_definitions.rb:31:in `to_sql'
    /Users/avishai/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-postgis-adapter-0.4.3/lib/active_record/connection_adapters/postgis_adapter/spatial_table_definition.rb:76:in `block in to_sql'
    /Users/avishai/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-postgis-adapter-0.4.3/lib/active_record/connection_adapters/postgis_adapter/spatial_table_definition.rb:76:in `map'
    /Users/avishai/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-postgis-adapter-0.4.3/lib/active_record/connection_adapters/postgis_adapter/spatial_table_definition.rb:76:in `to_sql'
    /Users/avishai/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-postgis-adapter-0.4.3/lib/active_record/connection_adapters/postgis_adapter/main_adapter.rb:192:in `create_table'
    /Users/avishai/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.9/lib/active_record/migration.rb:466:in `block in method_missing'
    /Users/avishai/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.9/lib/active_record/migration.rb:438:in `block in say_with_time'
    /Users/avishai/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.9/lib/active_record/migration.rb:438:in `say_with_time'
    /Users/avishai/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.9/lib/active_record/migration.rb:458:in `method_missing'

宝石文件:

gem "rails", "~> 3.2.9"
gem "airbrake"
gem "pg"
gem "postgres_ext"
gem "activerecord-postgis-adapter"
gem "activerecord-postgres-array", "~> 0.0.8"

任何想法如何解决这个问题?

4

1 回答 1

1

这是一个已知问题。问题是 activerecord-postgis-adapter 和 postgres_ext 对 ActiveRecord 中的 PostgreSQL 适配器有竞争补丁,解决方案是让 postgres_ext 或 activerecord-postgis-adapter 依赖于其他 gem。让 postgres_ext 依赖于 activerecord-postgis-adapter 是没有意义的,因为您不必使用 PostGIS 来使用 PostgreSQL 的本机数据类型

(我是 postgres_ext gem 的维护者,我刚刚注意到您是打开链接问题的人)

于 2013-01-16T13:58:30.067 回答