Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在RoR中的线程中运行刮刀_Ruby On Rails_Ruby_Ruby On Rails 5 - Fatal编程技术网

Ruby on rails 在RoR中的线程中运行刮刀

Ruby on rails 在RoR中的线程中运行刮刀,ruby-on-rails,ruby,ruby-on-rails-5,Ruby On Rails,Ruby,Ruby On Rails 5,我的RubyonRails应用程序中有两个scraper,我正在尝试将我的数据scraper运行到不同的线程中。 问题是我的scrapers存储在app/controllers/services/scrapers文件夹中,我无法在线程中访问此服务。请看下面的代码: threads = [] data.each_key do |office| threads << Thread.new(office, data) do |office1, data1|

我的RubyonRails应用程序中有两个scraper,我正在尝试将我的数据scraper运行到不同的线程中。 问题是我的scrapers存储在
app/controllers/services/scrapers
文件夹中,我无法在线程中访问此服务。请看下面的代码:

    threads = []

    data.each_key do |office|
      threads << Thread.new(office, data) do |office1, data1|
        data1[office1].each_key do |link|
          if (first condition)
            Services::Scrapers::FirstScraperService.new.parse(link, data1[office1][link])
          elsif (second condition)                      
            Services::Scrapers::SecondScraperService.new.parse(link, data1[office1][link])  
          end         
        end
      end
    end
    threads.each { |thr| thr.join } 

你能发布你的导演结构吗?这个问题很可能可以通过使用
::服务::…
来解决。试试看。@AkshayGoyal我已经在
服务::Scrapers::FirstScraperService
前面上传了这个结构,但它不起作用?@AkshayGoyal我已经尝试过了,但是遇到了另一个问题
警告已经初始化了常量服务
警告:以前的服务定义在这里
 app/controllers/services/scrapers