2017-07-14 88 views
0

我想在rails應用程序的ruby中使用resque。Ruby on Rails的resque任務獲取錯誤

我創建resque.rake文件中的lib/tasks文件夾

require 'resque/tasks' 

task 'resque:setup' => :environment 

我已經按照行啓動Redis的服務器

redis-server /usr/local/etc/redis.conf 

我有這個Rake文件在我的應用程序:

require_relative 'config/application' 

Rails.application.load_tasks 

但是,當我運行以下命令啓動耙

rake resque:work QUEUE='*' 

我得到這個錯誤:

LoadError: cannot load such file -- resque/tasks 

我看不到我錯過什麼,

有什麼建議?

謝謝。

注:我使用的鐵軌5.0.1

回答

0

在您可以添加這個軌道在config/application.rb

config.autoload_paths += %W(#{config.root}/lib) 
config.autoload_paths += Dir["#{config.root}/lib/**/"] 

不要擔心,這是很容易在Rails的文檔的錯過。本頁只是一個小提示

如果您想了解更多信息,請轉至此頁面並搜索「config.autoload_paths」。 http://guides.rubyonrails.org/autoloading_and_reloading_constants.html#autoload-paths

還取決於你如何構建應用程序(有或無證件)您可能會看到這個評論在application.rb中

Rails::Initializer.run do |config| 
    # Add additional load paths for your own custom dirs 
    # config.load_paths += %W(#{RAILS_ROOT}/extras) 
    config.load_paths << "#{RAILS_ROOT}/app/models/some_model_group" 
    config.load_paths << "#{RAILS_ROOT}/lib" 
end