2016-08-02 4 views
2

루비 레일 : 2.3.0p0주석 보석 구성주고 오류를

레일 버전 : 4.2.6

주석 보석 버전 :

: rails g annotate:install 일에 2.7.1

날이 오류를 제공합니다

(erb):34:in `template': uninitialized constant AnnotateModels (NameError) 
from /Users/newput/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/erb.rb:864:in `eval' 
from /Users/newput/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/erb.rb:864:in `result' 
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:116:in `block in template' 
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:53:in `render' 
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `block (2 levels) in invoke!' 
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `open' 
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `block in invoke!' 
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:116:in `invoke_with_conflict_check' 
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:60:in `invoke!' 
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions.rb:94:in `action' 
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:25:in `create_file' 
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:115:in `template' 
from /Users/newput/.rvm/gems/ruby-2.3.0/gems/annotate-2.7.1/lib/generators/annotate/install_generator.rb:9:in `copy_tasks' 

답변

4

이 방법으로 오류가 해결되는지 잘 모르겠지만 다음 단계에 따라 동일한 오류가 발생합니다.

$ rails new hi 
    $ cd hi 
    $ echo "gem 'annotate', '2.7.1', require: false" >> Gemfile 
    $ bundle 
    $ rails g annotate:install 
    Running via Spring preloader in process 29328 
     create lib/tasks/auto_annotate_models.rake 
    (erb):34:in `template': uninitialized constant AnnotateModels (NameError) 
      from /home/hibariya/.rbenv/versions/2.3.0/lib/ruby/2.3.0/erb.rb:864:in `eval' 
      from /home/hibariya/.rbenv/versions/2.3.0/lib/ruby/2.3.0/erb.rb:864:in `result' 
      from /home/hibariya/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:116:in `block in template' 
    ... 

이 오류는 미리 annotate-gem이 필요하므로 해결할 수 있다고 생각합니다. 그래서 Gemfile에서 require: falsegem 'annotate', '2.7.1', require: false에서 제거했을 때 오류가 수정되었습니다.

+0

나를 위해 일하지 않아! – shashank

+2

흠. Gemfile에 어떤 그룹 아래에'gem 'annotate'을 두었습니까? 그룹과 RAILS_ENV가 일치하지 않으면 보석이로드되지 않고 동일한 오류가 발생합니다. – hibariya

+1

감사합니다.'annotate'를 개발 번들로 옮깁니다. – shashank

관련 문제