Skip to content

Instantly share code, notes, and snippets.

@rishiip
Forked from rishi-amura/bson.rb
Created March 10, 2016 06:11
Show Gist options
  • Save rishiip/4da70bc4ecb5a72811c3 to your computer and use it in GitHub Desktop.
Save rishiip/4da70bc4ecb5a72811c3 to your computer and use it in GitHub Desktop.
Return mongo `_id` bson object as regular `id` within Rails application
Save below code to `bson.rb` file within `config/initializers` directory and restart the server
module BSON
class ObjectId
def as_json(*args)
to_s
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment