• 什么时候 = = 恰巧在北京

  • 别回去了,现在挺好的

  • ubuntu 终端开启很慢 at 2015年01月16日

    突然感觉我的 2~3s 算快的了

  • ActiveRecord 读取记录问题... at 2015年01月14日

    #3 楼 @ripple 解决了 thx!

  • ActiveRecord 读取记录问题... at 2015年01月14日

    #1 楼 @heylonj

    NoMethodError - undefined method `username' for #<User::ActiveRecord_Relation:0x000000037468c0>:
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0/lib/active_record/relation/delegation.rb:136:in `method_missing'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0/lib/active_record/relation/delegation.rb:99:in `method_missing'
        game.rb:77:in `block in <class:Game>'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `block in compile!'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `[]'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (3 levels) in route!'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:985:in `route_eval'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (2 levels) in route!'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:1006:in `block in process_route'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `catch'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `process_route'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:964:in `block in route!'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `each'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `route!'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:1076:in `block in dispatch!'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:1073:in `dispatch!'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `block in call!'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `call!'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:886:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/rack-protection-1.5.0/lib/rack/protection/xss_header.rb:18:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/rack-protection-1.5.0/lib/rack/protection/base.rb:49:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/rack-protection-1.5.0/lib/rack/protection/base.rb:49:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/rack-protection-1.5.0/lib/rack/protection/path_traversal.rb:16:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/rack-protection-1.5.0/lib/rack/protection/json_csrf.rb:18:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/rack-protection-1.5.0/lib/rack/protection/base.rb:49:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/rack-protection-1.5.0/lib/rack/protection/base.rb:49:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/rack-protection-1.5.0/lib/rack/protection/frame_options.rb:31:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/rack-1.6.0/lib/rack/session/abstract/id.rb:225:in `context'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/rack-1.6.0/lib/rack/session/abstract/id.rb:220:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/rack-1.6.0/lib/rack/nulllogger.rb:9:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/rack-1.6.0/lib/rack/head.rb:13:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/show_exceptions.rb:21:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:180:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:2014:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `block in call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:1788:in `synchronize'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/thin-1.6.3/lib/thin/connection.rb:86:in `block in pre_process'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/thin-1.6.3/lib/thin/connection.rb:84:in `catch'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/thin-1.6.3/lib/thin/connection.rb:84:in `pre_process'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/eventmachine-1.0.3/lib/eventmachine.rb:1037:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/eventmachine-1.0.3/lib/eventmachine.rb:1037:in `block in spawn_threadpool'
    Unexpected error while processing request: undefined method `join' for #<String:0x007fd98855e538>
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/show_exceptions.rb:37:in `rescue in call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/show_exceptions.rb:21:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:180:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:2014:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `block in call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:1788:in `synchronize'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/thin-1.6.3/lib/thin/connection.rb:86:in `block in pre_process'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/thin-1.6.3/lib/thin/connection.rb:84:in `catch'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/thin-1.6.3/lib/thin/connection.rb:84:in `pre_process'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/eventmachine-1.0.3/lib/eventmachine.rb:1037:in `call'
        /home/yushao/.rvm/gems/ruby-2.1.5/gems/eventmachine-1.0.3/lib/eventmachine.rb:1037:in `block in spawn_threadpool'
    
    
    
  • sinatra 中计划任务的问题 at 2015年01月14日

    #3 楼 @ywjno thx!问题解决了 现在的 rufus-scheduler 创建的时候用.new 取代了.start_new 但是测试还是有点问题... 下面的代码是每秒输出一次 unix 时间。。但输出的结果有时间隔会在 2s

    require 'sinatra'
    require 'rufus/scheduler'
    
    configure do
      scheduler = Rufus::Scheduler.new 
      # test
      scheduler.every '1s' do
        puts Time.now.to_i
      end
    end
    
    get '/' do
      "start work at #{Time.new.strftime('%Y-%m-%d %H:%M:%S')}"
    end
    

    这是输出的结果

    1421213271
    1421213272
    1421213273
    1421213274
    1421213276
    1421213277
    1421213278
    1421213279
    1421213280
    1421213282
    1421213283
    
    

    猜想是因为间隔太短。。可是调到了 5s 以后依然这样

    1421213425
    1421213430
    1421213436
    1421213441
    1421213446
    1421213451
    1421213456
    1421213461
    
  • rails 数据关联的问题 at 2014年12月25日