-
Notifications
You must be signed in to change notification settings - Fork 805
Description
OK, I know that STI is frowned upon here, but my application is what it is. ;-)
I'm seeing a SystemStackError when I try to import a model participating in an STI configuration.
class User < ActiveRecord::Base
import UserSearchable
...
end
class ApiKey < User
...
end
User.import
works as expected, but when I try to import ApiKey
, I get a SystemStackError
.
I've tracked it down to Elasticsearch::Model::Proxy::Base
, and tried some basic/ugly debugging:
def method_missing(method_name, *arguments, &block)
sleep(1)
puts "caller: #{caller.first}"
puts "class : #{self.class.inspect}"
puts "method: #{method_name}"
puts "args : #{arguments}"
puts "target: #{target.inspect}"
puts "respon: #{target.respond_to?(method_name)}"
puts "_________________________"
target.respond_to?(method_name) ? target.__send__(method_name, *arguments, &block) : super
end
Which yields the following:
2.1.2 :002 > ApiKey.import
caller: /Users/arustad/.rvm/gems/ruby-2.1.2/gems/elasticsearch-model-0.1.4/lib/elasticsearch/model.rb:112:in `import'
class : Elasticsearch::Model::Proxy::ClassMethodsProxy
method: import
args : []
target: ApiKey(id: integer, ...)
respon: true
_________________________
caller: /Users/arustad/.rvm/gems/ruby-2.1.2/gems/elasticsearch-model-0.1.4/lib/elasticsearch/model.rb:112:in `import'
class : Elasticsearch::Model::Proxy::ClassMethodsProxy
method: import
args : []
target: ApiKey(id: integer, ...)
respon: true
_________________________
... REPEAT...
target.respond_to?(:import)
returns true
, so it calls target.__send__
on ApiKey. It then of course eventually raises a SystemStackError.
Any advice would be helpful. I know @karmi doesn't like STI all that much, but I am hoping to solve this either by modifying the elasticsearch ruby source or adjusting my application in some way (hopefully not changing the STI relationship).
Thanks!
AR.