• @hooopo

    2012-12-14 15:05:52
    ****************************************************************************************************
    

    异常

    2012-12-15T17:53:28Z 4184 TID-ovrw0mpy0 WARN: invalid date
    2012-12-15T17:53:28Z 4184 TID-ovrw0mpy0 WARN: /Users/stephen/Gupiao/app/workers/stockspider_worker.rb:16:in `parse'
    /Users/stephen/Gupiao/app/workers/stockspider_worker.rb:16:in `block in perform'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/mongoid-3.0.1/lib/mongoid/contextual/mongo.rb:672:in `yield_and_increment'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/mongoid-3.0.1/lib/mongoid/contextual/mongo.rb:134:in `block (2 levels) in each'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/moped-1.1.6/lib/moped/query.rb:78:in `block in each'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/moped-1.1.6/lib/moped/cursor.rb:26:in `block in each'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/moped-1.1.6/lib/moped/cursor.rb:26:in `each'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/moped-1.1.6/lib/moped/cursor.rb:26:in `each'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/moped-1.1.6/lib/moped/query.rb:77:in `each'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/moped-1.1.6/lib/moped/query.rb:77:in `each'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/mongoid-3.0.1/lib/mongoid/contextual/mongo.rb:133:in `block in each'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/mongoid-3.0.1/lib/mongoid/contextual/mongo.rb:632:in `selecting'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/mongoid-3.0.1/lib/mongoid/contextual/mongo.rb:132:in `each'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/mongoid-3.0.1/lib/mongoid/contextual.rb:18:in `each'
    /Users/stephen/Gupiao/app/workers/stockspider_worker.rb:9:in `perform'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/processor.rb:36:in `block (3 levels) in process'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/middleware/chain.rb:75:in `call'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/middleware/chain.rb:75:in `block in invoke'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/middleware/server/timeout.rb:14:in `call'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/middleware/chain.rb:77:in `block in invoke'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/middleware/server/active_record.rb:6:in `call'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/middleware/chain.rb:77:in `block in invoke'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/middleware/server/retry_jobs.rb:30:in `call'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/middleware/chain.rb:77:in `block in invoke'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/logging.rb:22:in `with_context'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/middleware/server/logging.rb:7:in `call'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/middleware/chain.rb:77:in `block in invoke'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/middleware/server/exception_handler.rb:9:in `call'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/middleware/chain.rb:77:in `block in invoke'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/middleware/chain.rb:80:in `call'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/middleware/chain.rb:80:in `invoke'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/processor.rb:35:in `block (2 levels) in process'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/processor.rb:66:in `stats'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/sidekiq-1.2.1/lib/sidekiq/processor.rb:34:in `block in process'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/celluloid-0.10.0/lib/celluloid/calls.rb:56:in `call'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/celluloid-0.10.0/lib/celluloid/calls.rb:56:in `dispatch'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/celluloid-0.10.0/lib/celluloid/future.rb:18:in `block in initialize'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/celluloid-0.10.0/lib/celluloid/thread_pool.rb:46:in `call'
    /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/celluloid-0.10.0/lib/celluloid/thread_pool.rb:46:in `block in create'
    
  • @hooopo 我原来也是有个空格的,但是 14 楼说是空白造成,所以,我去掉了空格

  • @hooopo 呵呵,我也这样做了,这是输入结果!

    2012-12-1415:05:52
    ****************************************************************************************************
    
  • @hooopo 输出不了,因为在 parse 那里已经错误,没有执行 log

  • @hooopo

    # encoding: utf-8
    require 'net/http'
    require 'iconv'
    
    class StockspiderWorker
      include Sidekiq::Worker
    
      def perform
        Stock.all.each do |stock|
          @s = Net::HTTP.get(URI.parse("http://hq.sinajs.cn/list=" + stock[:market] + stock[:code]))
          @s = @s[@s.index("\"")+1, @s.rindex("\"")-1]
          @records = @s.split(",")
          stock.update_attributes(:name => Iconv.iconv("UTF-8", "GBK", @records[0]).first.to_s, 
            :volume => @records[8], :obv => @records[9], 
            :op => @records[1], :ycp => @records[2], 
            :cp => @records[3], :tp => @records[4], 
            :lp => @records[5], 
            :got_at => DateTime.parse("#{@records[30]}#{@records[31]}"))
        end
      end
    end
    
  • @hooopo 用 DateTime.parse 也和 strptime 一样

  • @hooopo 有 date,应该不能用 time,试了试,报错

    2012-12-15T14:06:44Z 2229 TID-oxdpfwkik WARN: no time information in " "
    2012-12-15T14:06:44Z 2229 TID-oxdpfwkik WARN: /Users/stephen/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/time.rb:267:in `parse'
    
  • @hooopo 是的,所以我想不明白,看他报错,应该是 date 的参数验证错误,但是搞不明白!

  • @hooopo 恩恩,是的,因为是这里调用了。

  • @hooopo

    Rails.logger.info("#{@records[30]} #{@records[31]}")
    Rails.logger.info(DateTime.strptime("#{@records[30]} #{@records[31]}", '%Y-%m-%d %H:%M:%S'))
    

    结果分别是

    2012-12-14 15:05:52
    2012-12-14T15:05:52+00:00
    
  • @stephen 在 sidekiq 的 worker 中用 puts 打印出来吗?好似打印不了!2 楼的结构就是我把 worker 里的代码在 rails c 中执行一次的结果,应该一样的吧?

  • @hooopo

    1.9.3p125 :006 > DateTime.parse("#{@records[30]} #{@records[31]}")
     => Fri, 14 Dec 2012 15:03:07 +0000 
    
    1.9.3p125 :005 > DateTime.strptime("#{@records[30]} #{@records[31]}", '%Y-%m-%d %H:%M:%S')
     => Fri, 14 Dec 2012 15:03:07 +0000 
    
  • @winnie 缺货!

  • 牛啊!

  • @xinzhi 请问如何把文章里的图片链接作为文章列表的配图?

  • @woaigithub 哈哈,这位仁兄好似问非所答啊!!!难道你有兴趣?金融行业的投资网站,

  • 自由发挥呗!@woaigithub

  • 用了再改,改了再用,周而复此!等考虑完了,都做出来了,用自己最方便最熟悉的开始!

  • 是 devise 问题,还是 UPYUN 的验证呢?没用 UPYUN 的时候,没这个错误出现的

  • 提交表单的时候

  • @huacnlee 谢谢,这个问题有遇到嘛?

    RestClient::unauthorized in AccountsController#update
    401 Unautorized
    
  • @huacnlee 出现这个错误了 undefined method `attract_accessor` for

  • @huyong36 恩恩,正解,是要把这个 action 用 skip 跳过自动加载就可以了

  • @zgm 换了,不过还是一样的错误!

  • @cantin 没加权限,好似不关权限问题。

  • @cantin

    Mongoid::Errors::DocumentNotFound (
    Problem:
      Document(s) not found for class Topic with id(s) 1.
    Summary:
      When calling Topic.find with an id or array of ids, each parameter must match a document in the database or this error will be raised. The search was for the id(s): 1 ... (1 total) and the following ids were not found: 1.
    Resolution:
      Search for an id that is in the database or set the Mongoid.raise_not_found_error configuration option to false, which will cause a nil to be returned instead of raising this error when searching for a single id, or only the matched documents when searching for multiples.):
      mongoid (3.0.1) lib/mongoid/criteria.rb:550:in `check_for_missing_documents!'
      mongoid (3.0.1) lib/mongoid/criteria.rb:177:in `execute_or_raise'
      mongoid (3.0.1) lib/mongoid/criteria.rb:255:in `find'
      mongoid (3.0.1) lib/mongoid/finders.rb:61:in `find'
      cancan (1.6.8) lib/cancan/model_adapters/abstract_adapter.rb:20:in `find'
      cancan (1.6.8) lib/cancan/controller_resource.rb:114:in `find_resource'
      cancan (1.6.8) lib/cancan/controller_resource.rb:68:in `load_resource_instance'
      cancan (1.6.8) lib/cancan/controller_resource.rb:32:in `load_resource'
      cancan (1.6.8) lib/cancan/controller_resource.rb:25:in `load_and_authorize_resource'
      cancan (1.6.8) lib/cancan/controller_resource.rb:10:in `block in add_before_filter'
      activesupport (3.2.9) lib/active_support/callbacks.rb:429:in `_run__4281606112534886323__process_action__491492952496635975__callbacks'
      activesupport (3.2.9) lib/active_support/callbacks.rb:405:in `__run_callback'
      activesupport (3.2.9) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
      activesupport (3.2.9) lib/active_support/callbacks.rb:81:in `run_callbacks'
      actionpack (3.2.9) lib/abstract_controller/callbacks.rb:17:in `process_action'
      actionpack (3.2.9) lib/action_controller/metal/rescue.rb:29:in `process_action'
      actionpack (3.2.9) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
      activesupport (3.2.9) lib/active_support/notifications.rb:123:in `block in instrument'
      activesupport (3.2.9) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
      activesupport (3.2.9) lib/active_support/notifications.rb:123:in `instrument'
      actionpack (3.2.9) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
      actionpack (3.2.9) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
      actionpack (3.2.9) lib/abstract_controller/base.rb:121:in `process'
      actionpack (3.2.9) lib/abstract_controller/rendering.rb:45:in `process'
      actionpack (3.2.9) lib/action_controller/metal.rb:203:in `dispatch'
      actionpack (3.2.9) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
      actionpack (3.2.9) lib/action_controller/metal.rb:246:in `block in action'
      actionpack (3.2.9) lib/action_dispatch/routing/route_set.rb:73:in `call'
      actionpack (3.2.9) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
      actionpack (3.2.9) lib/action_dispatch/routing/route_set.rb:36:in `call'
      journey (1.0.4) lib/journey/router.rb:68:in `block in call'
      journey (1.0.4) lib/journey/router.rb:56:in `each'
      journey (1.0.4) lib/journey/router.rb:56:in `call'
      actionpack (3.2.9) lib/action_dispatch/routing/route_set.rb:601:in `call'
      mongoid (3.0.1) lib/rack/mongoid/middleware/identity_map.rb:33:in `block in call'
      mongoid (3.0.1) lib/mongoid/unit_of_work.rb:39:in `unit_of_work'
      mongoid (3.0.1) lib/rack/mongoid/middleware/identity_map.rb:33:in `call'
      warden (1.1.1) lib/warden/manager.rb:35:in `block in call'
      warden (1.1.1) lib/warden/manager.rb:34:in `catch'
      warden (1.1.1) lib/warden/manager.rb:34:in `call'
      actionpack (3.2.9) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
      rack (1.4.1) lib/rack/etag.rb:23:in `call'
      rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
      actionpack (3.2.9) lib/action_dispatch/middleware/head.rb:14:in `call'
      actionpack (3.2.9) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
      actionpack (3.2.9) lib/action_dispatch/middleware/flash.rb:242:in `call'
      rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
      rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
      actionpack (3.2.9) lib/action_dispatch/middleware/cookies.rb:341:in `call'
      actionpack (3.2.9) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
      activesupport (3.2.9) lib/active_support/callbacks.rb:405:in `_run__884117061507234179__call__1917505127064085281__callbacks'
      activesupport (3.2.9) lib/active_support/callbacks.rb:405:in `__run_callback'
      activesupport (3.2.9) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
      activesupport (3.2.9) lib/active_support/callbacks.rb:81:in `run_callbacks'
      actionpack (3.2.9) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
      actionpack (3.2.9) lib/action_dispatch/middleware/reloader.rb:65:in `call'
      actionpack (3.2.9) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
      actionpack (3.2.9) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
      actionpack (3.2.9) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
      railties (3.2.9) lib/rails/rack/logger.rb:32:in `call_app'
      railties (3.2.9) lib/rails/rack/logger.rb:16:in `block in call'
      activesupport (3.2.9) lib/active_support/tagged_logging.rb:22:in `tagged'
      railties (3.2.9) lib/rails/rack/logger.rb:16:in `call'
      quiet_assets (1.0.1) lib/quiet_assets.rb:20:in `call_with_quiet_assets'
      actionpack (3.2.9) lib/action_dispatch/middleware/request_id.rb:22:in `call'
      rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
      rack (1.4.1) lib/rack/runtime.rb:17:in `call'
      activesupport (3.2.9) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
      rack (1.4.1) lib/rack/lock.rb:15:in `call'
      actionpack (3.2.9) lib/action_dispatch/middleware/static.rb:62:in `call'
      rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
      rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
      rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
      rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
      rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
      railties (3.2.9) lib/rails/engine.rb:479:in `call'
      railties (3.2.9) lib/rails/application.rb:223:in `call'
      rack (1.4.1) lib/rack/content_length.rb:14:in `call'
      railties (3.2.9) lib/rails/rack/log_tailer.rb:17:in `call'
      thin (1.5.0) lib/thin/connection.rb:81:in `block in pre_process'
      thin (1.5.0) lib/thin/connection.rb:79:in `catch'
      thin (1.5.0) lib/thin/connection.rb:79:in `pre_process'
      thin (1.5.0) lib/thin/connection.rb:54:in `process'
      thin (1.5.0) lib/thin/connection.rb:39:in `receive_data'
      eventmachine (1.0.0) lib/eventmachine.rb:187:in `run_machine'
      eventmachine (1.0.0) lib/eventmachine.rb:187:in `run'
      thin (1.5.0) lib/thin/backends/base.rb:63:in `start'
      thin (1.5.0) lib/thin/server.rb:159:in `start'
      rack (1.4.1) lib/rack/handler/thin.rb:13:in `run'
      rack (1.4.1) lib/rack/server.rb:265:in `start'
      railties (3.2.9) lib/rails/commands/server.rb:70:in `start'
      railties (3.2.9) lib/rails/commands.rb:55:in `block in <top (required)>'
      railties (3.2.9) lib/rails/commands.rb:50:in `tap'
      railties (3.2.9) lib/rails/commands.rb:50:in `<top (required)>'
      script/rails:6:in `require'
      script/rails:6:in `<main>'
    
    
      Rendered /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/actionpack-3.2.9/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.1ms)
      Rendered /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/actionpack-3.2.9/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.8ms)
      Rendered /Users/stephen/.rvm/gems/ruby-1.9.3-p125/gems/actionpack-3.2.9/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (10.6ms)
    
  • @cantin 确定是/topics/node1,同 ruby-china 一样,我在学习 ruby-china,我的 route.rb

    match "topics/node:id" => "topics#node", :as => :node_topics
      match "topics/node:id/feed" => "topics#node_feed", :as => :feed_node_topics
      match "topics/last" => "topics#recent", :as => :recent_topics
      resources :topics do
        member do
          post :reply
          post :favorite
          post :follow
          post :unfollow
        end
        collection do
          get :no_reply
          get :popular
          get :feed
          post :preview
        end
        resources :replies
      end
    
  • DHH 当爹了 at 2012年11月22日

    我以为 DHH 坑爹了!

  • @chenge 新版需要吗?我的版本和 ruby-china 一样,但是 ruby-china 好像也没有这一句!