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
pemilas committed Jan 18, 2014
1 parent 47abb0b commit 078202f
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 078202f

Please sign in to comment.