Skip to content

Instantly share code, notes, and snippets.

@rishi-amura
Created February 26, 2016 11:37
Show Gist options
  • Save rishi-amura/d8aaf2515c8af5453ff6 to your computer and use it in GitHub Desktop.
Save rishi-amura/d8aaf2515c8af5453ff6 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