开发者社区> 问答> 正文

使用ruby的activerecord连接RDS for PPAS报错是什么原因

使用ruby的activerecord(版本4.1.1)连接RDS for PPAS报错,单连接本地的PG 9.3不报错。也可以通过Navicat连接RDS for PPAS成功。

错误信息:

ActiveRecord::Base.establish_connection(:dbname => 'postgres', :host => '121.199.103.187', :port => 3444,:user => 'xxx' , :password => 'xxx', :adapter => "postgresql")

class FirstLevelAsset < ActiveRecord::Base
end

irb(main):027:0> FirstLevelAsset.first
=> #

TypeError: no implicit conversion of String into Integer
from /usr/local/rvm/gems/ruby-2.1.4/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:769:in `[]'
from /usr/local/rvm/gems/ruby-2.1.4/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:769:in `add_oid'
from /usr/local/rvm/gems/ruby-2.1.4/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:777:in `add_oid'
from /usr/local/rvm/gems/ruby-2.1.4/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:802:in `block in initialize_type_map'
from /usr/local/rvm/gems/ruby-2.1.4/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:801:in `each'
from /usr/local/rvm/gems/ruby-2.1.4/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:801:in `initialize_type_map'
from /usr/local/rvm/gems/ruby-2.1.4/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:577:in `initialize'
from /usr/local/rvm/gems/ruby-2.1.4/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
from /usr/local/rvm/gems/ruby-2.1.4/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
from /usr/local/rvm/gems/ruby-2.1.4/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection'
from /usr/local/rvm/gems/ruby-2.1.4/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection'
from /usr/local/rvm/gems/ruby-2.1.4/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection'
from /usr/local/rvm/gems/ruby-2.1.4/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'
from /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
from /usr/local/rvm/gems/ruby-2.1.4/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout'
from /usr/local/rvm/gems/ruby-2.1.4/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
... 25 levels...
from /usr/local/rvm/gems/ruby-2.1.4/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `load'
from /usr/local/rvm/gems/ruby-2.1.4/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `block in load'
from /usr/local/rvm/gems/ruby-2.1.4/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
from /usr/local/rvm/gems/ruby-2.1.4/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `load'
from /usr/local/rvm/gems/ruby-2.1.4/gems/spring-1.3.6/lib/spring/commands/rails.rb:6:in `call'
from /usr/local/rvm/gems/ruby-2.1.4/gems/spring-1.3.6/lib/spring/command_wrapper.rb:38:in `call'
from /usr/local/rvm/gems/ruby-2.1.4/gems/spring-1.3.6/lib/spring/application.rb:183:in `block in serve'
from /usr/local/rvm/gems/ruby-2.1.4/gems/spring-1.3.6/lib/spring/application.rb:156:in `fork'
from /usr/local/rvm/gems/ruby-2.1.4/gems/spring-1.3.6/lib/spring/application.rb:156:in `serve'
from /usr/local/rvm/gems/ruby-2.1.4/gems/spring-1.3.6/lib/spring/application.rb:131:in `block in run'
from /usr/local/rvm/gems/ruby-2.1.4/gems/spring-1.3.6/lib/spring/application.rb:125:in `loop'
from /usr/local/rvm/gems/ruby-2.1.4/gems/spring-1.3.6/lib/spring/application.rb:125:in `run'
from /usr/local/rvm/gems/ruby-2.1.4/gems/spring-1.3.6/lib/spring/application/boot.rb:18:in `'
from /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'

展开
收起
明虚 2015-12-18 16:26:42 1774 0
1 条回答
写回答
取消 提交回答
  • PostgreSQL、Greenplum内核开发

    原因找到了,是activerecord版本的原因,使用activerecord 4.0.2或者4.2都没有问题。

    2019-07-16 11:49:53
    赞同 2 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
TcpRT:阿里云RDS智能诊断系统云上大规模部署自动化服务的客户实践经验 立即下载
TcpRT:面向大规模海量云数据库的服务质量实时采集与诊断系 立即下载
袋鼠云基于阿里云RDS的数据库架构实践 立即下载

相关镜像