HTTParty:未定义的方法`代码'错误

时间:2013-04-19 13:27:09

标签: ruby httparty

获取错误:./ http.rb:13:#(NoMethodError)的未定义方法`code'

#!/usr/bin/ruby

require 'rubygems'
require 'httparty'

class Foo
  include HTTParty
end

# Simple get with full url
r = Foo.get('http://www.google.com/')

p r.code

1 个答案:

答案 0 :(得分:0)

包含HTTParty也将指定模块的方法代码添加到Foo类。见mixin

module HTTParty
  module AllowedFormatsDeprecation
    def get
      #...
    end
  end
end
混合HTTParty到Foo应该工作