You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Thing < ActiveRecord::Base
include Elasticsearch::Model
def as_indexed_json(options={})
default = self.__elasticsearch__.as_indexed_json(options) # <--
other = {
# whatever
}
default.merge(other)
end
end
Wanting to extend the default behavior (intuitive, DRY, OO) causes infinite recursion.
Soon I'll submit a pull request.
The text was updated successfully, but these errors were encountered:
I don't see a good reason to call self.__elasticsearch__.as_indexed_json inside your own implementation. There is nothing special about that method, and you should simply implement it yourself, with the as_json provided by ActiveModel/ActiveSupport or by building the Hash.
@aercolino Hey, closing this, it's been some time. Let me repeat again, that there is no need whatsoever for you to call the self.__elasticsearch__.as_indexed_json method. Just serialize your model to a Hash with whatever means you have.
Wanting to extend the default behavior (intuitive, DRY, OO) causes infinite recursion.
Soon I'll submit a pull request.
The text was updated successfully, but these errors were encountered: