使用ruby的activerecord连接RDS for PPAS报错是什么原因-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

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

明虚 2015-12-18 16:26:42 498

使用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'

Java 关系型数据库 PostgreSQL Ruby Spring RDS
分享到
取消 提交回答
全部回答(1)
  • 明虚
    2019-07-16 11:49:53

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

    2 0
数据库
使用钉钉扫一扫加入圈子
+ 订阅

分享数据库前沿,解构实战干货,推动数据库技术变革

推荐文章
相似问题
推荐课程