gpt4 book ai didi

ruby-on-rails-4 - 注释 gem rails 配置给出错误

转载 作者:行者123 更新时间:2023-12-04 02:10:48 24 4
gpt4 key购买 nike

ruby :2.3.0p0

Rails 版本:4.2.6

注释gem版本:2.7.1

在执行 rails g annotate:install 时出现此错误:

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

最佳答案

我不确定这是否解决了您的错误,但我按照以下步骤遇到了同样的错误:

  $ 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 中的 gem 'annotate', '2.7.1', require: false 中删除 require: false 时,错误得到修复。

关于ruby-on-rails-4 - 注释 gem rails 配置给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38717864/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com