how to annotate rails models in rails version 3.2.1

我是研究僧i 提交于 2019-12-10 13:39:25

问题


Im trying to follow some online tutorial on annotating my models in rails. However, it seems all the tutorials are either talking about outdated annotation versions or incorrect installations its a mess.

So far Ive tried the following

1) Added this in the Gemfile

gem 'annotate', '2.4.0'

2) Then the command:

bundle install

3) I then saw that the annotation gem was installed and showing up on the command

bundle show

4) lastly in order to annotate my models I used the command

bundle exec annotate --position before

At this point I was expecting my models to be annotated however what I got was the following error message:

/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>'

So feeling completely stumped.

Any ideas on how to proceed?

Thanks


回答1:


Try using the updated beta version.

gem 'annotate', '2.4.1.beta1'



回答2:


Also you may try this gem annotated-rails.



来源:https://stackoverflow.com/questions/9652220/how-to-annotate-rails-models-in-rails-version-3-2-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!