【发布时间】:2017-05-14 23:54:15
【问题描述】:
这是我在project github 上写的内容的完整副本。请原谅我的交叉发帖,但我希望这里有人遇到了这个错误:
undefined method `st_point' for #
<ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition:0x0055cdd8f278e8>
这是我的 Gemfile 锁:
activerecord (4.2.7.1)
activerecord-postgis-adapter (3.1.4)
以及迁移:
class CreateLocations < ActiveRecord::Migration
def change
enable_extension "postgis"
create_table :locations do |t|
t.st_point :geom, geographic: true, srid: 4326, dimension: 2
t.timestamps
end
end
end
奇怪的是这在开发模式下有效。只是当我为测试环境运行迁移时它失败了。
在rake db:create RAILS_ENV=test 之后,我使用psql 连接到测试数据库并运行CREATE EXTENSION postgis;。
tl;dr
t.st_point在迁移中是未定义的,只在测试环境中。
【问题讨论】:
标签: ruby-on-rails ruby postgresql activerecord postgis