Skip to content

Instantly share code, notes, and snippets.

@saadbinakhlaq
Created September 24, 2016 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saadbinakhlaq/1d841ea3360acf150647269df6131e00 to your computer and use it in GitHub Desktop.
Save saadbinakhlaq/1d841ea3360acf150647269df6131e00 to your computer and use it in GitHub Desktop.
module BSON
class ObjectId
def to_json(*args)
to_s.to_json
end
def as_json(*args)
to_s.as_json
end
end
end
module Mongoid
module Document
def serializable_hash(options = nil)
hash = super(options)
hash['id'] = hash.delete('_id') if(hash.has_key?('_id'))
hash
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment