简体   繁体   English

未初始化的常量Rails :: Generators(NameError)

[英]uninitialized constant Rails::Generators (NameError)

I'm updating the code for a generator that I wrote, but has been working fine until now. 我正在更新我编写的生成器的代码,但直到现在一直工作正常。

When I simply rue the command 当我简单地发出命令时

bundle exec rails g

I get the following error 我收到以下错误

/Users/mpierc200/projects/prototype_conflux/vendor/gems/itrc_client_files_generator-1.0.13/lib/itrc_client_files_generator.rb:6:in `<top (required)>':
uninitialized constant Rails::Generators (NameError)

The offending line is 违规行是

class ItrcClientFilesGenerator < Rails::Generators::Base

My Rails version is 我的Rails版本是

Rails 3.1.9

ruby version is 红宝石版是

ruby 1.9.3p194

It looks like the Rails generator modules were pulled out and not automatically loaded at some point during Rails 3 development. 看起来Rails生成器模块被拉出并且在Rails 3开发期间的某个时刻没有自动加载。 This is probably for good reasons. 这可能是有充分理由的。

You have to include them in custom generators: 您必须将它们包含在自定义生成器中:

require 'rails/generators'

class ItrcClientFilesGenerator < Rails::Generators::Base
  # Fancy generator code here
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM