我将 ActiveRecod 与我的 sinatra 应用程序和 mysql db 一起使用,直到昨天都运行良好。今天我遇到了奇怪的错误。在使用 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]
我的 gem 版本如下
1.8.11
解决了
突然,我停下来遇到同样的错误。我已经删除了之前存在的 ruby 1.8,之后我没有遇到错误。仍然需要对此进行任何解释,因为我不知道是什么解决了这个问题。