2016-04-19 7 views
-1

私は、アプリケーションから機能のチャンクをカプセル化するための宝石を作成しています。それらの宝石は、基本的にrakeタスクを実行しますが、私はbundle exec rake:assets:precompileでタスクを実行すると、私は次のようなエラーにNameError:初期化されていない定数GemName :: Rails :: Railtie

rake aborted! 
Bundler::GemRequireError: There was an error while trying to load the gem 'gem-name'. 
/Users/tonyedwardspz/myprojects/westcornwallevents/config/application.rb:8:in `<top (required)>' 
/Users/tonyedwardspz/myprojects/westcornwallevents/Rakefile:4:in `require' 
/Users/tonyedwardspz/myprojects/westcornwallevents/Rakefile:4:in `<top (required)>' 
NameError: uninitialized constant GemName::Rails::Railtie 
/Users/tonyedwardspz/myprojects/westcornwallevents/config/application.rb:8:in `<top (required)>' 
/Users/tonyedwardspz/myprojects/westcornwallevents/Rakefile:4:in `require' 
/Users/tonyedwardspz/myprojects/westcornwallevents/Rakefile:4:in `<top (required)>' 

を得るrailtieに関連するモジュールのコードは次のとおりです。なぜ私はすべてのアイデアを

require 'rails' 

module GemName 
    module Rails 
    class Railtie < Rails::Railtie 
     railtie_name :gem_name 

     rake_tasks do 
     load "tasks/gem_name.rake" 
     end 
    end 
    end 
end 

このエラーが出ていますか?

答えて

0

エラーは、クラス定義の構文にあります。以下のようにコードを更新すると、レーキタスクが実行されます。

class Railtie < ::Rails::Railtie 

class Railtie < Rails::Railtie 

関連する問題