【发布时间】:2016-04-19 11:19:11
【问题描述】:
我正在创建一个 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
知道为什么我会收到此错误吗?
【问题讨论】:
标签: ruby-on-rails railtie