How to annotate rail models in rails version 3.2.1

I am trying to follow some online tutorial on annotating my models in rails. However, it seems that all the tutorials either talk about outdated versions of annotations, or about incorrect installations, which is a mess.

So far ive tried the following

1) Added to Gemfile

gem 'annotate', '2.4.0' 

2) Then the command:

 bundle install 

3) Then I saw that the annotation label was set and displayed on command

 bundle show 

4) Finally, 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, I got 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, I feel completely at a standstill.

Any ideas on how to proceed?

thanks

+6
source share
2 answers

Try using the updated beta.

 gem 'annotate', '2.4.1.beta1' 
+5
source

You can also try this annotated-rails gem.

0
source

Source: https://habr.com/ru/post/910428/


All Articles