2013-11-22 31 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”中。删除后,连接工作正常。

相关问题