2011-08-09 79 views
7

我遇到一個例外,而在Rails的3未定義的方法`訪問者對Rails 3的DB:遷移

undefined method `visitor' for #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0x00000103dea3d8> 

做數據庫遷移編輯

請檢查該解決方案here


沒有出現的字符串visitor我的項目裏面,所以我很不解。

這裏是完全轉儲:

$ rake db:migrate --trace 
** Invoke db:migrate (first_time) 
** Invoke environment (first_time) 
** Execute environment 
** Invoke db:load_config (first_time) 
** Invoke rails_env (first_time) 
** Execute rails_env 
** Execute db:load_config 
** Execute db:migrate 
rake aborted! 
undefined method `visitor' for #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0x00000103dea3d8> 
.rvm/gems/ruby-1.9.2-p180/gems/arel-2.1.5/lib/arel/tree_manager.rb:19:in `visitor' 
.rvm/gems/ruby-1.9.2-p180/gems/arel-2.1.5/lib/arel/tree_manager.rb:23:in `to_sql' 
.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc5/lib/active_record/migration.rb:562:in `get_all_versions' 
.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc5/lib/active_record/migration.rb:708:in `migrated' 
.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc5/lib/active_record/migration.rb:635:in `current_version' 
.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc5/lib/active_record/migration.rb:652:in `block in migrate' 
.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc5/lib/active_record/migration.rb:652:in `each' 
.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc5/lib/active_record/migration.rb:652:in `detect' 
.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc5/lib/active_record/migration.rb:652:in `migrate' 
.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc5/lib/active_record/migration.rb:545:in `up' 
.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc5/lib/active_record/migration.rb:526:in `migrate' 
.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc5/lib/active_record/railties/databases.rake:161:in `block (2 levels) in <top (required)>' 
.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:205:in `call' 
.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute' 
.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:200:in `each' 
.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute' 
.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain' 
.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' 
.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain' 
.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke' 
.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task' 
.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level' 
.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:90:in `each' 
.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level' 
.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling' 
.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level' 
.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run' 
.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling' 
.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:59:in `run' 
.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/bin/rake:32:in `<top (required)>' 
.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `load' 
.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `<main>' 
Tasks: TOP => db:migrate 
+1

謝謝!這讓我瘋狂...... – Clay

+0

請添加您的解決方案作爲答案並接受它。 – iwasrobbed

+0

謝謝@iWasRobbed – lbz

回答

3

看起來像阿雷爾2.1.5的問題;加入gem "arel", "2.1.4"到相關的Gemfile將解決問題。

Source

相關問題