GeekedOut
GeekedOut

Reputation: 17185

Errors trying to connect to Ruby API

I am making my way through these instructions https://github.com/phifty/agraph/blob/master/README.rdoc

And I installed the gem fine, and the program seems to not be complaining after I require the gem.

The problem happens when tring to connect to that database with this code:

server = AllegroGraph::Server.new :username => "user", :password => "pass"
repository = AllegroGraph::Repository.new server, "test_repository"
repository.create_if_missing!

I am new to RoR so I think my question is silly, but when I just add this code, I get a syntax error. When I add the @ character at the beginning of a line to make it a variable, I also get errors.

How can I use this code as part of my Ruby script? And what I am doing wrong?

The error I get is:

uninitialized constant HomeController::Allegrograph

Upvotes: 0

Views: 81

Answers (1)

jshen
jshen

Reputation: 11917

If your using rails 3 you need to add the gem to your Gemfile. If on rails 2 you need to require the gem.

If that doesn't work, try this

server = ::AllegroGraph::Server.new :username => "user", :password => "pass"

Upvotes: 1

Related Questions