-
-
Save rishiip/4da70bc4ecb5a72811c3 to your computer and use it in GitHub Desktop.
Return mongo `_id` bson object as regular `id` within Rails application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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