http://stackoverflow.com/questions/19299806/how-to-make-a-rails-4-api-with-mongoid-orm-an-oauth2-provider

Moped's BSON has been removed of bson gem 2.0, but you may add this manually.
Create config/initializers/bson/object_id.rb Into file add:

module Moped
  module BSON
    ObjectId = ::BSON::ObjectId

    class Document < Hash
      class << self
        def deserialize(io, document = new)
          __bson_load__(io, document)
        end

        def serialize(document, io = "")
          document.__bson_dump__(io)
        end
      end
    end
  end
end