Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uninitialized constant ::ActiveResource

I try to call an API. I just want use active resource so I make this code in a simple file .rb:

class Order < ActiveResource::Base
    self.site = "http://localhost:3000/api/"
    self.element_name = "order"
    self.format = ActiveResource::Formats::XmlFormat
end

When I call this file who should do the init he throw me an error:

$ ruby test/test_order.rb 
test/test_order.rb:1:in `<main>': uninitialized constant ActiveRessource (NameError)

I try to create a new rvm gemset and just install activeresource

rvm gemset create delete_me
rvm use 1.9.3@delete_me
gem install activeresource

He throw me the same error. I try with ruby 1.9.2 same error.

The activeresource's version I've try is 3.1.3 and 3.2.6

Thanks.

like image 218
Guillaume Avatar asked Jan 16 '23 10:01

Guillaume


1 Answers

You need to require ActiveResource. You can do that like so:

require 'active_resource'

You will also probably need to require rubygems before your require activeresource:

require 'rubygems'
require 'active_resource'
like image 155
Olly Avatar answered Jan 25 '23 22:01

Olly