我的系统上有 HTTParty gem,我可以在 Rails 中使用它。
现在我想单独使用它。
我正在尝试:
class Stuff
include HTTParty
def self.y
HTTParty.get('http://www.google.com')
end
end
Stuff.y
但是我明白了
$ ruby test_httparty.rb
test_httparty.rb:2:in `<class:Stuff>': uninitialized constant Stuff::HTTParty (NameError)
from test_httparty.rb:1:in `<main>'
07:46:52 durrantm Castle2012 /home/durrantm/Dropnot/_/rails_apps/linker 73845718_get_method
$
最佳答案
你必须要求'httpparty'
:
require 'httparty'
class Stuff
include HTTParty
# ...
end
关于ruby - 为什么会出现未初始化常量 Stuff::HTTPParty 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24407941/