我正在使用ActiveRecod与我的sinatra应用程序和mysql数据库,直到昨天工作正常。今天我有一些奇怪的错误。使用mysql2作为适配器时遇到以下错误。
irb(main):008:0> ActiveRecord::Base.establish_connection(:adapter=>"mysql2",:host=>"localhost",:username=>"tushar",:password=>"samael321",:database=>"Chat_test")
NameError: uninitialized constant Arel::Visitors::MySQL
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:466:in `rescue in load_missing_constant'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:462:in `load_missing_constant'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:106:in `const_missing_with_dependencies'
from /var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:128:in `<class:AbstractMysqlAdapter>'
from /var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:6:in `<module:ConnectionAdapters>'
from /var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:5:in `<module:ActiveRecord>'
from /var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:4:in `<top (required)>'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:182:in `block in require'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:547:in `new_constants_in'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:182:in `require'
from /var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:1:in `<top (required)>'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:182:in `block in require'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:547:in `new_constants_in'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:182:in `require'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_specification.rb:69:in `establish_connection'
from (irb):8
from /usr/bin/irb:12:in `<main>'
我无法在网上弄清楚这个问题。
我的红宝石版本如下:
ruby 1.9.3p0 (2011-10-30 revision 33570) [i686-linux]
我的宝石版本如下
1.8.11
解决
突然间,我已停止遇到任何错误。我删除了之前存在的ruby 1.8,之后我没有遇到错误。仍然需要对此进行任何解释,因为我不知道是什么解决了这个问题。