2013-02-14 94 views
5

我正在更新我編寫的生成器的代碼,但直到現在一直工作正常。未初始化的常量Rails ::生成器(NameError)

當我簡直後悔命令

bundle exec rails g 

我收到以下錯誤

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

出錯行是

class ItrcClientFilesGenerator < Rails::Generators::Base 

我的Rails的版本是

Rails 3.1.9 

紅寶石版本

ruby 1.9.3p194 
+0

難道這不是基於斷碼[你寫(http://stackoverflow.com/questions/12500469/how-to-implement-generators - 對於-A-插件定位,在最LIB-插件名稱,可怕的)? – 2013-02-14 21:01:25

+0

是的,違規行在我寫的文件中。 – 2013-02-14 21:02:08

+0

嘗試'require'rails/generators/generated_attribute''。基於[這個答案](http://stackoverflow.com/a/2594602/403664)。 – 2013-02-14 21:04:15

回答

9

它看起來像Rails的發生器模塊被掏出,並在Rails 3的開發過程中的一些點自動加載。這可能是有原因的。

你必須包括他們的自定義生成器:

require 'rails/generators' 

class ItrcClientFilesGenerator < Rails::Generators::Base 
    # Fancy generator code here 
end 
相關問題