Skip to content

Commit

Permalink
[MODEL] Updated the Mongoid example in the README to include `as_inde…
Browse files Browse the repository at this point in the history
…xed_json` method

Default Mongoid serialization keeps the `_id` property in the JSON as "BSON Object",
which breaks Elasticsearch.

See:

* elastic/elasticsearch#3517
* rails-api/active_model_serializers#354 (comment)
  • Loading branch information
miniTalDev committed Jan 18, 2014
1 parent 63a414e commit 86e70ec
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions elasticsearch-model/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,10 @@ class Article
attr_accessible :id, :title, :published_at

include Elasticsearch::Model

def as_indexed_json(options={})
as_json(except: [:id, :_id])
end
end

Article.create id: '1', title: 'Quick brown fox'
Expand Down

0 comments on commit 86e70ec

Please sign in to comment.