2013-02-14 20 views
5

私が書いたジェネレータのコードを更新していますが、今まではうまくいきました。未初期化定数Rails :: Generators(NameError)

私は単に私が問題のある行が

class ItrcClientFilesGenerator < Rails::Generators::Base 

私のRailsのバージョンは

Rails 3.1.9 
である次のエラー

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

をgetコマンド

bundle exec rails g 

を後悔

ルビーバージョンはRailsの発電モジュールを引き出し、自動的にRailsの3開発中のある時点でロードされていなかったように見えます

ruby 1.9.3p194 
+0

は、このオフに基づいてコードではありません[あなたが書いた](http://stackoverflow.com/questions/12500469/how-to-implement-generators -for-a-plugin-located-the-lib-plugin-name-dire)を使用していますか? –

+0

はい、問題の行は私が書いたファイルにあります。 –

+0

'require 'rails/generators/generated_attribute''を試してください。 [この回答](http://stackoverflow.com/a/2594602/403664)に基づいています。 –

答えて

9

です。おそらくこれは良い理由があります。カスタムジェネレータでそれらを含める必要が

require 'rails/generators' 

class ItrcClientFilesGenerator < Rails::Generators::Base 
    # Fancy generator code here 
end 
関連する問題