简体   繁体   中英

Heroku fails to perform clockwork delayed tasks

I am having a clockwork configuration file(inside the lib folder) that queues another file's methods to perform delayed tasks.

require_relative "Adwords/Extractor"

It is working fine on my local machine (WEBrick running on win8). However on heroku, it is failing with the following error:

 'app[web.1]: /app/lib/clock.rb:5:in `require_relative': cannot load such file -- /app/li
  b/Adwords/Extractor (LoadError)'

The Extractor.rb script is located at the same place as mentioned by the error statement.

In Ruby 1.9.2 or higher no longer make the current directory . part of your LOAD_PATH.

You can get around it by using absolute paths

File.expand_path(__FILE__) et al

or doing

require './filename' (ironically).

or by using

require_relative 'filename'

require './filename' 

only works if your script is executed with the working directory set to the same directory that the script resides. This is often not the case in multi-directory projects.

try this out

require "#{Rails.root}/app/lib/Adwords/Extractor"

use relative path to rails app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM