我有这个奇怪的错误(对我来说)我无法弄清楚为什么会发生。
有时当我致电RestClient.get 'http://google.com'
时,我收到了回复,有时我收到此错误undefined method '<<' for true:TrueClass
我正在使用Rails 4.1.8,Ruby 2.1.5p273和RestClient 1.7.2
2.1.5 :010 > RestClient.get 'https://google.com'
NoMethodError: undefined method `<<' for true:TrueClass
from /home/ivan/.rvm/gems/ruby-2.1.5/gems/rest-client-1.7.2/lib/restclient/request.rb:525:in `log_request'
from /home/ivan/.rvm/gems/ruby-2.1.5/gems/rest-client-1.7.2/lib/restclient/request.rb:410:in `transmit'
from /home/ivan/.rvm/gems/ruby-2.1.5/gems/rest-client-1.7.2/lib/restclient/request.rb:176:in `execute'
from /home/ivan/.rvm/gems/ruby-2.1.5/gems/rest-client-1.7.2/lib/restclient/request.rb:41:in `execute'
from /home/ivan/.rvm/gems/ruby-2.1.5/gems/rest-client-1.7.2/lib/restclient.rb:65:in `get'
from (irb):10
from /home/ivan/.rvm/gems/ruby-2.1.5/gems/railties-4.1.8/lib/rails/commands/console.rb:90:in `start'
from /home/ivan/.rvm/gems/ruby-2.1.5/gems/railties-4.1.8/lib/rails/commands/console.rb:9:in `start'
from /home/ivan/.rvm/gems/ruby-2.1.5/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:69:in `console'
from /home/ivan/.rvm/gems/ruby-2.1.5/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /home/ivan/.rvm/gems/ruby-2.1.5/gems/railties-4.1.8/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
答案 0 :(得分:0)
您的RestClient.log
设置为true
。通过拦截二传手来查找发生的位置:
def RestClient.log=(value)
raise "HERE!"
end
然后等待直到触发异常,并从堆栈跟踪中查看谁分配了愚蠢的值。 :)