我试图按照一些在线教程注释我的模型在rails中。然而,似乎所有的教程都在讨论过时的注释版本或不正确的安装它是一团糟。
到目前为止,我已尝试过以下
1)在Gemfile中添加了这个
gem 'annotate', '2.4.0'
2)然后命令:
bundle install
3)然后我看到注释gem已经安装并显示在命令
上bundle show
4)最后,为了注释我的模型,我使用了命令
bundle exec annotate --position before
此时我期待我的模型被注释但是我得到的是以下错误消息:
/Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/railties/databases.rake:4:in `<top (required)>': undefined method `namespace' for main:Object (NoMethodError)
from /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/railtie.rb:33:in `load'
from /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/railtie.rb:33:in `block in <class:Railtie>'
from /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `instance_exec'
from /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `block in load_tasks'
from /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `each'
from /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `load_tasks'
from /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/engine.rb:423:in `block in load_tasks'
from /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/application/railties.rb:8:in `each'
from /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/application/railties.rb:8:in `all'
from /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/engine.rb:423:in `load_tasks'
from /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/application.rb:145:in `load_tasks'
from /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
from Rakefile:7:in `<top (required)>'
from /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/annotate-2.4.0/lib/annotate.rb:17:in `load'
from /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/annotate-2.4.0/lib/annotate.rb:17:in `load_tasks'
from /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/annotate-2.4.0/bin/annotate:66:in `<top (required)>'
from /Users/AM/.rvm/gems/ruby-1.9.2-p290/bin/annotate:19:in `load'
from /Users/AM/.rvm/gems/ruby-1.9.2-p290/bin/annotate:19:in `<main>'
感觉完全难过。
关于如何进行的任何想法?
由于
答案 0 :(得分:5)
尝试使用更新的测试版。
gem 'annotate', '2.4.1.beta1'
答案 1 :(得分:0)
你也可以尝试这个宝石annotated-rails。