我正在创建一个 gem 来封装应用程序的一大块功能。他们 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
任何想法为什么我会收到此错误?