我已成功安装PostGIS并使用postgres_ext
gem添加支持Rails postgis
ActiveRecord适配器,但是当我尝试在迁移中使用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'
的Gemfile:
gem "rails", "~> 3.2.9"
gem "airbrake"
gem "pg"
gem "postgres_ext"
gem "activerecord-postgis-adapter"
gem "activerecord-postgres-array", "~> 0.0.8"
有任何想法如何解决这个问题?
答案 0 :(得分:1)
This is a known issue。问题是activerecord-postgis-adapter和postgres_ext在ActiveRecord中有对PostgreSQL适配器的竞争补丁,解决方法是让postgres_ext或activerecord-postgis-adapter依赖于另一个gem。将postgres_ext依赖于activerecord-postgis-adapter是没有意义的,因为你不必使用PostGIS来使用PostgreSQL的本机数据类型
(我是postgres_ext gem的维护者,我只是注意到你是打开链接问题的人)