Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get the error uninitialized constant Stuff::HTTParty?

I have the HTTParty gem on my system and I can use it from within rails.

Now I want to use it standalone.

I am trying:

class Stuff
  include HTTParty
  def self.y
    HTTParty.get('http://www.google.com')
  end 
end
Stuff.y

but I get

$ 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
$ 
like image 531
Michael Durrant Avatar asked Jun 25 '14 11:06

Michael Durrant


1 Answers

You have to require 'httparty':

require 'httparty'

class Stuff
  include HTTParty
  # ...
end
like image 119
Stefan Avatar answered Nov 05 '22 00:11

Stefan