• At.js v0.2.0-beta. :) at January 06, 2013

    支持!

  • @kenneth 解决了吗?

  • @shanks 是验证问题,你看看你的空间是否开启了允许外链

  • @hooopo

    str_got_at = "#{@records[30]} #{@records[31]}"
          Rails.logger.info(str_got_at)
          Rails.logger.info(str_got_at.encoding)
          Rails.logger.info(str_got_at.bytes.to_a.inspect)
          Rails.logger.info "*" * 100
          got_at = DateTime.parse(Iconv.iconv("UTF-8", "GBK", str_got_at).first.to_s)
    
    2012-12-14 15:05:52
    ASCII-8BIT
    [50, 48, 49, 50, 45, 49, 50, 45, 49, 52, 32, 49, 53, 58, 48, 53, 58, 53, 50]
    2012-12-14 15:05:52
    ****************************************************************************************************
    
  • @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 没加权限,好似不关权限问题。