安装了annotate-2.4.0后执行bundle exec annotate报错:
/home/reddevil/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/railties/databases.rake:4:in `<top (required)>\': undefined method `namespace\' for main:Object (NoMethodError) from /home/reddevil/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/railtie.rb:33:in `load\' from /home/reddevil/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.3/lib/active_record/railtie.rb:33:in `block in <class:Railtie>\' from /home/reddevil/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/railtie.rb:184:in `instance_exec\' from /home/reddevil/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/railtie.rb:184:in `block in load_tasks\' from /home/reddevil/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/railtie.rb:184:in `each\' from /home/reddevil/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/railtie.rb:184:in `load_tasks\' from /home/reddevil/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/engine.rb:423:in `block in load_tasks\' from /home/reddevil/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/application/railties.rb:8:in `each\' from /home/reddevil/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/application/railties.rb:8:in `all\' from /home/reddevil/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/engine.rb:423:in `load_tasks\' from /home/reddevil/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/application.rb:145:in `load_tasks\' from /home/reddevil/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing\' from Rakefile:7:in `<top (required)>\' from /home/reddevil/.rvm/gems/ruby-1.9.3-p194/gems/annotate-2.4.0/lib/annotate.rb:17:in `load\' from /home/reddevil/.rvm/gems/ruby-1.9.3-p194/gems/annotate-2.4.0/lib/annotate.rb:17:in `load_tasks\' from /home/reddevil/.rvm/gems/ruby-1.9.3-p194/gems/annotate-2.4.0/bin/annotate:66:in `<top (required)>\' from /home/reddevil/.rvm/gems/ruby-1.9.3-p194/bin/annotate:19:in `load\' from /home/reddevil/.rvm/gems/ruby-1.9.3-p194/bin/annotate:19:in `<main>\' from /home/reddevil/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval\' from /home/reddevil/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>\'
查了一下对这个问题已经有了一个patch:
http://stackoverflow.com/questions/7295505/annotate-gem-and-rails-3-1
https://github.com/ctran/annotate_models/commit/8057b920968a4c64c7d558e43834f81867329fcc
按照上述方法即可消除该问题
reddevil@reddevil-Lenovo:~/railsProject/demo_app/sample_app$ bundle update annotate
reddevil@reddevil-Lenovo:~/railsProject/demo_app/sample_app$ bundle exec annotate Annotated (1): User