-
Notifications
You must be signed in to change notification settings - Fork 792
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
Model.import causes stack level too deep error #144
Comments
@tomciopp That would be really surprising, since there's lot of integration tests for the feature.
Don't know what you mean, but I use the import method in Rails console and Pry quite frequently. It would be good if you provide info on what exactly you're doing and all the stacktraces! |
It looks like the error was on my side. One of the classes in an application I am working on did not follow the convention for naming in rails. Fixing this issue also fixed the issues I was having with Model.import. |
We also get this error! This is caused by rails single table inheriance: class A < ActiveRecord::Base
include Elasticsearch::Model
end
class B < A
end
class C < A
end
# then if you try to import the jobs you get the error described above
B.import
C.import
A.import # works |
I've the same issue as @arfl described |
@karmi @arfl @stepankuzmin any updates on this problem with STI ? Did any of you get any chance to resolve it. Also if you can share some gist for STI search would be great. I am have very hard time with it. Previously, I was working with tire and it was working like a charm. |
I'll try to look into that later in the month, focused on something else right now, sorry! |
Hi guys, I had this same issue in an abstract base class, by instead doing instance_eval on the subclass fixed it. I added the following method: def self.inherited(child)
super
child.instance_eval do
# Elastic search functionality!
include Elasticsearch::Model
# Automatically update the index on change
include Elasticsearch::Model::Callbacks
end
end |
Thanks @jlaw90, your code solved this issue for me. |
@karmi I haven't looked at the source for this gem, but I guess the issue must be that when the module is included it's using the class name to then cache the index, type and other parameters. This is all conjecture though, I don't know if there's anything else funky going on Edit: thinking about it, additional problems could be caused if adding class methods to the including class. Really it's difficult to debug these sorts of problems, it might be best to write some tests and then go from there. |
@jlaw90 Thanks!, I'll have a look at that when I'm back onlilne properly. |
The underlying problem is with the proxied methods. The "practical" solution seems to be include the |
Currently when I try to use the import class method provided by elasticsearch-model, I run into
SystemStackError: stack level too deep
. It looks like it runs into an error in irb and pry when they try to runeval
on the code. This causes errors to occur in the rake tasks as well. I am running version 3.2.16 of ActiveRecord.The text was updated successfully, but these errors were encountered: