[英]Trouble adding st_point column with activerecord-postgis-adapter
这是我在项目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;博士
仅在测试环境中,迁移中的t.st_point
是未定义的。
错误是ENV [“ DATABASE_URL”]中的“ postgres”而不是“ postgis”
那是别人在线程上建议的。 我很固执,没有检查,但这是正确的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.