我正在创建一个gem来封装应用程序的一部分功能。它们基本上运行一个rake任务,但是当我使用bundle exec rake:assets:precompile运行该任务时,我会得到以下错误
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知道我为什么会犯这个错误吗?
发布于 2016-04-19 11:19:11
错误出现在类定义的语法中。按照以下方式更新代码将允许运行rake任务。
class Railtie < Rails::Railtie至
class Railtie < ::Rails::Railtiehttps://stackoverflow.com/questions/36716846
复制相似问题