使用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'
原因找到了,是activerecord版本的原因,使用activerecord 4.0.2或者4.2都没有问题。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。