本文介绍了作业加载失败:未初始化的常量Syck :: Syck的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用延迟作业(collectiveideas分支)在后台运行方法

I am running a method in the background using delayed-job (collectiveideas fork)

我正在运行的方法如下所示,该方法获取isbn的价格:

The method I am running is shown below, which fetches the price of the isbn:

  def update_prices(isbn13)
   @amazon = Nokogiri::XML(open("http://www.amazon.com/s/?url=search-alias%3Daps&field-keywords=#{isbn13}"))
   price = @amazon.search('span.listprice').first.text.gsub('$', '')

   book = Book.find_by_isbn13(isbn13)
   book.update_attribute(:amazon_us_price, price)
  end
  handle_asynchronously :update_prices

现在,当我运行此命令时,该作业已添加到数据库,但在运行时遇到错误。
该错误很大,但我认为要点在于第一行:
作业无法加载:未初始化的常量Syck :: Syck。

Now when I run this, the job is added to the database but encounters an error when running.The error is quite large, but I think the gist of it comes from the first line:Job failed to load: uninitialized constant Syck::Syck.

{Job failed to load: uninitialized constant Syck::Syck. Handler: "--- !ruby/struct:Delayed::PerformableMethod 
object: &id005 !ruby/object:BooksController 
  _action_name: show
  _config: !omap []

  _env: &id001 
    GATEWAY_INTERFACE: CGI/1.1
    PATH_INFO: /books/9780425160985
    QUERY_STRING: \"\"
    REMOTE_ADDR: 127.0.0.1
    REMOTE_HOST: localhost
    REQUEST_METHOD: GET
    REQUEST_URI: http://localhost:3000/books/9780425160985
    SCRIPT_NAME: \"\"
    SERVER_NAME: localhost
    SERVER_PORT: \"3000\"
    SERVER_PROTOCOL: HTTP/1.1
    SERVER_SOFTWARE: WEBrick/1.3.1 (Ruby/1.9.2/2010-08-18)
    HTTP_HOST: localhost:3000
    HTTP_CONNECTION: keep-alive
    HTTP_REFERER: http://localhost:3000/books/search?utf8=%E2%9C%93&keywords=hornets+nest&commit=Search
    HTTP_ACCEPT: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.107 Safari/534.13
    HTTP_ACCEPT_ENCODING: gzip,deflate,sdch
    HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.8
    HTTP_ACCEPT_CHARSET: ISO-8859-1,utf-8;q=0.7,*;q=0.3
    HTTP_COOKIE: _bookcloud_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRiIlMTNkZWFlYTdiYjVjN2IzZDAyOTU1MDc1NTc1ZDJlZDBJIhBfY3NyZl90b2tlbgY7AEZJIjFrUHJoT0RlZmZoSzIrSVdFdFJNbGxMckxENEZnMTM1STZuQUJCdHJuak1BPQY7AEY%3D--c2b7958a5461253129b6d363e3d547bd44c83f9d
    rack.version: 
    - 1
    - 1
    rack.input: !ruby/object:StringIO {}

    rack.errors: !ruby/object:IO {}

    rack.multithread: false
    rack.multiprocess: false
    rack.run_once: false
    rack.url_scheme: http
    HTTP_VERSION: HTTP/1.1
    REQUEST_PATH: /
    action_dispatch.parameter_filter: 
    - :password
    action_dispatch.secret_token: ab805f7bf1e681785a2ac4813edc43678cbe855682bc7ca9dc5f2116fc892d8ca41466f9bc261ef4ae15ad83c1c38780780d2f6bfe9c00c14abd68542a535400
    action_dispatch.remote_ip: !ruby/object:ActionDispatch::RemoteIp::RemoteIpGetter 
      check_ip_spoofing: true
      env: *id001
      trusted_proxies: !ruby/regexp /(^127\\.0\\.0\\.1$|^(10|172\\.(1[6-9]|2[0-9]|30|31)|192\\.168)\\.)/i
    rack.session: !map:ActionDispatch::Session::AbstractStore::SessionHash 
      session_id: 13deaea7bb5c7b3d02955075575d2ed0
      _csrf_token: kPrhODeffhK2+IWEtRMllLrLD4Fg135I6nABBtrnjMA=
    rack.session.options: !map:ActionDispatch::Session::AbstractStore::OptionsHash 
      :path: /
      :domain: 
      :expire_after: 
      :secure: false
      :httponly: true
      :id: 13deaea7bb5c7b3d02955075575d2ed0
    rack.request.cookie_string: _bookcloud_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRiIlMTNkZWFlYTdiYjVjN2IzZDAyOTU1MDc1NTc1ZDJlZDBJIhBfY3NyZl90b2tlbgY7AEZJIjFrUHJoT0RlZmZoSzIrSVdFdFJNbGxMckxENEZnMTM1STZuQUJCdHJuak1BPQY7AEY%3D--c2b7958a5461253129b6d363e3d547bd44c83f9d
    rack.request.cookie_hash: 
      _bookcloud_session: BAh7B0kiD3Nlc3Npb25faWQGOgZFRiIlMTNkZWFlYTdiYjVjN2IzZDAyOTU1MDc1NTc1ZDJlZDBJIhBfY3NyZl90b2tlbgY7AEZJIjFrUHJoT0RlZmZoSzIrSVdFdFJNbGxMckxENEZnMTM1STZuQUJCdHJuak1BPQY7AEY=--c2b7958a5461253129b6d363e3d547bd44c83f9d
    action_dispatch.cookies: !map:ActionDispatch::Cookies::CookieJar 
      _bookcloud_session: BAh7B0kiD3Nlc3Npb25faWQGOgZFRiIlMTNkZWFlYTdiYjVjN2IzZDAyOTU1MDc1NTc1ZDJlZDBJIhBfY3NyZl90b2tlbgY7AEZJIjFrUHJoT0RlZmZoSzIrSVdFdFJNbGxMckxENEZnMTM1STZuQUJCdHJuak1BPQY7AEY=--c2b7958a5461253129b6d363e3d547bd44c83f9d
    action_dispatch.request.unsigned_session_cookie: 
      session_id: 13deaea7bb5c7b3d02955075575d2ed0
      _csrf_token: kPrhODeffhK2+IWEtRMllLrLD4Fg135I6nABBtrnjMA=
    action_dispatch.request.path_parameters: 
      :controller: books
      :action: show
      :isbn13: \"9780425160985\"
    action_controller.instance: *id005
    action_dispatch.request.content_type: 
    action_dispatch.request.request_parameters: !map:ActiveSupport::HashWithIndifferentAccess {}

    rack.request.query_string: \"\"
    rack.request.query_hash: {}

    action_dispatch.request.query_parameters: !map:ActiveSupport::HashWithIndifferentAccess {}

    action_dispatch.request.parameters: &id002 !map:ActiveSupport::HashWithIndifferentAccess 
      controller: books
      action: show
      isbn13: \"9780425160985\"
    action_dispatch.request.formats: 
    - !ruby/object:Mime::Type 
      string: text/html
      symbol: :html
      synonyms: 
      - application/xhtml+xml
  _headers: 
    Content-Type: text/html
  _params: *id002
  _request: &id003 !ruby/object:ActionDispatch::Request 
    env: *id001
    filtered_parameters: 
      controller: books
      action: show
      isbn13: \"9780425160985\"
    fullpath: /books/9780425160985
    method: GET
    request_method: GET
  _response: !ruby/object:ActionDispatch::Response 
    blank: false
    block: 
    body: []

    cache_control: {}

    cookie: []

    etag: 
    header: {}

    length: 0
    request: *id003
    sending_file: false
    status: 200
    writer: !ruby/object:Proc {}

  _response_body: 
  _status: 200
  action_has_layout: true
  author: Patricia Daniels Cornwell
  book: !ruby/ActiveRecord:Book 
    attributes: 
      isbn13: \"9780425160985\"
      title: Hornet's Nest
      author: Patricia Daniels Cornwell
      price: 
      created_at: &id004 2011-03-03 10:41:27.757528 Z
      updated_at: *id004
      amazon_us_price: 
      id: 38
  lookup: !ruby/object:Nokogiri::XML::Document 
    decorators: 
    errors: []

    node_cache: 
    - !ruby/object:Nokogiri::XML::Element {}

    - !ruby/object:Nokogiri::XML::Element {}

    - !ruby/object:Nokogiri::XML::Element {}

  lookup_context: !ruby/object:ActionView::LookupContext 
    details: 
      :handlers: 
      - :erb
      - :rjs
      - :builder
      - :rhtml
      - :rxml
      :formats: 
      - :html
      :locale: 
      - :en
      - :en
    details_key: 
    frozen_formats: false
    skip_default_locale: false
    view_paths: !seq:ActionView::PathSet 
      - !ruby/object:ActionView::FileSystemResolver 
        cached: {}

        caching: false
        path: /Users/nick/Dropbox/rails/bookcloud/app/views
  title: Hornet's Nest
  view_context_class: 
method_name: :update_prices_without_delay
args: 
- \"9780425160985\"
"
/Users/nick/.rvm/gems/ruby-1.9.2-p0@rorticket/gems/delayed_job-2.1.4/lib/delayed/backend/base.rb:81:in `rescue in payload_object'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@rorticket/gems/delayed_job-2.1.4/lib/delayed/backend/base.rb:79:in `payload_object'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@rorticket/gems/delayed_job-2.1.4/lib/delayed/backend/base.rb:87:in `invoke_job'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@rorticket/gems/delayed_job-2.1.4/lib/delayed/worker.rb:120:in `block (2 levels) in run'
/Users/nick/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/timeout.rb:57:in `timeout'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@rorticket/gems/delayed_job-2.1.4/lib/delayed/worker.rb:120:in `block in run'
/Users/nick/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@rorticket/gems/delayed_job-2.1.4/lib/delayed/worker.rb:119:in `run'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@rorticket/gems/delayed_job-2.1.4/lib/delayed/worker.rb:177:in `reserve_and_run_one_job'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@rorticket/gems/delayed_job-2.1.4/lib/delayed/worker.rb:104:in `block in work_off'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@rorticket/gems/delayed_job-2.1.4/lib/delayed/worker.rb:103:in `times'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@rorticket/gems/delayed_job-2.1.4/lib/delayed/worker.rb:103:in `work_off'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@rorticket/gems/delayed_job-2.1.4/lib/delayed/worker.rb:78:in `block (2 levels) in start'
/Users/nick/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@rorticket/gems/delayed_job-2.1.4/lib/delayed/worker.rb:77:in `block in start'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@rorticket/gems/delayed_job-2.1.4/lib/delayed/worker.rb:74:in `loop'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@rorticket/gems/delayed_job-2.1.4/lib/delayed/worker.rb:74:in `start'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@rorticket/gems/delayed_job-2.1.4/lib/delayed/tasks.rb:9:in `block (2 levels) in <top (required)>'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@global/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@global/gems/rake-0.8.7/lib/rake.rb:636:in `block in execute'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@global/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@global/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@global/gems/rake-0.8.7/lib/rake.rb:597:in `block in invoke_with_call_chain'
/Users/nick/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@global/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@global/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@global/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@global/gems/rake-0.8.7/lib/rake.rb:2029:in `block (2 levels) in top_level'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@global/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@global/gems/rake-0.8.7/lib/rake.rb:2029:in `block in top_level'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@global/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@global/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@global/gems/rake-0.8.7/lib/rake.rb:2001:in `block in run'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@global/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@global/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@global/gems/rake-0.8.7/bin/rake:31:in `<top (required)>'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@global/bin/rake:19:in `load'
/Users/nick/.rvm/gems/ruby-1.9.2-p0@global/bin/rake:19:in `<main>'

任何想法都可能导致错误吗?我以前从未听说过Syck。

Any idea what may be causing the error? I have never heard of Syck before.

推荐答案

boot.rb(config\ boot.rb)

require 'yaml'
YAML::ENGINE.yamler= 'syck'

这篇关于作业加载失败:未初始化的常量Syck :: Syck的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 07:58