[英]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.