-
Notifications
You must be signed in to change notification settings - Fork 803
ElasticSearch::Model does not register a subclass #1072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I will note that if you explicitly include |
I do see this in the README:
Does this apply to subclasses outside of STI? I suppose it might. |
A proposed PR is here: https://github.com/elastic/elasticsearch-rails/pull/1073/files -- if this is a valid issue and repair, I will add tests to the PR. I signed the contributor's agreement. |
A subclass of a class that includes
Elasticsearch::Model
is not registered. This yields a crash when searching on the subclass.Specifically, this method in lib/elasticsearch/model/adapters/multiple.rb returns
nil
becausedetect
cannot find the subclass in the registry.This is not working code, but it is illustrative of the problem.
This is the code in lib/elasticsearch/model.rb that fails to add a class to the registry when it is a subclass...
The line
Registry.add(base) if base.is_a?(Class)
should likely be copied to adef inherited(subclass)
method like so...... to account for the subclassing. As is, only the first class to include
Elasticsearch::Model
is instrumented.The text was updated successfully, but these errors were encountered: