My goal is to connect with my heroku/mongolab database but I keep getting this error:
Mongo::OperationFailure at /mongotest/a/b
: need to login
file: networking.rb
location: send_message_with_gle
line: 89
The code I'm using is:
client = Mongo::MongoClient.from_uri(ENV['MONGOLAB_URI'])
db = client.db('test')
testcoll = db['testcoll']
testcoll.insert({:'_id' => "def", :'test' => "woop de doop"})
testcoll.find()
ENV['MONGOLAB_URI']=mongodb://heroku_app########:password@ds0xxxxx.mongolab.com:xxxxx/heroku_app########
I know that the uri is correct and contains the username and password, so why the error? Also, the error occurs on the insert() line, not the line where I authenticate.