2013-11-22 35 views
0

我正在使用rails 3.2.15。我有兩個postgresql數據庫,其中一個是主要的,另一個是postgis。從型號Postgis我連接到Postgis數據庫是這樣的:生產模式中的導軌不連接到第二個數據庫

class Postgis < ActiveRecord::Base 
    establish_connection :postgis_db 
    self.table_name = 'geometry_columns' 
    self.inheritance_column = :_type_disabled 
end 

在開發模式中一切正常。但是,當我切換到生產Web服務器無法啓動,下一個異常

gems/activerecord-3.2.15/lib/active_record/connection_adapters/postgresql_adapter.rb:1163:in `exec': PG::UndefinedTable: ERROR: relation "postgis" does not exist (ActiveRecord::StatementInvalid) 
LINE 5:    WHERE a.attrelid = '"postgis"'::regclass 
             ^
:    SELECT a.attname, format_type(a.atttypid, a.atttypmod), 
        pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod 
       FROM pg_attribute a LEFT JOIN pg_attrdef d 
       ON a.attrelid = d.adrelid AND a.attnum = d.adnum 
      WHERE a.attrelid = '"postgis"'::regclass 
       AND a.attnum > 0 AND NOT a.attisdropped 
      ORDER BY a.attnum 

它沒有連接到數據庫的PostGIS,並設法找到了PostGIS表中主數據庫。我嘗試用不同的方法連接到postgis數據庫,但結果是一樣的。

編輯:

的database.yml:

postgis_db: 
    adapter: postgresql 
    encoding: utf8 
    reconnect: false 
    database: mydb_gis 
    pool: 5 
    username: osmsrv 
    password: osmsrv 
    host: localhost 
    schema_search_path: public 
production: 
    adapter: postgresql 
    encoding: utf8 
    reconnect: false 
    database: gis 
    pool: 5 
    username: osmsrv 
    password: osmsrv 
    host: localhost 
+0

如果您在連接到正確的數據庫時遇到問題,您是否認爲展示如何嘗試連接以及在更改連接詳細信息時會發生什麼? –

回答

1

我解決了這個問題。 大約10天前,我做了連接到第二個數據庫的模型,它工作正常。當我切換到生產時,我確信連接在開發中起作用,但我錯了。在開發中連接也不起作用。問題出現在gem'texticle'「2.0」中。刪除後,連接工作正常。

相關問題