Skip to content

Commit 28e3124

Browse files
committed
[MODEL] Fixed incorrect proxy setup, including modules to class, not metaclass
Previously, models were registering adapters in a "last one wins" manner, so ActiveRecord models were trying to use Mongoid adapters, for example.
1 parent 3f69153 commit 28e3124

File tree

1 file changed

+4
-3
lines changed
  • elasticsearch-model/lib/elasticsearch

1 file changed

+4
-3
lines changed

elasticsearch-model/lib/elasticsearch/model.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,11 @@ def as_indexed_json(options={})
108108

109109
# Mix the importing module into the proxy
110110
#
111-
self.__elasticsearch__.class.__send__ :include, Elasticsearch::Model::Importing::ClassMethods
112-
self.__elasticsearch__.class.__send__ :include, Adapter.from_class(base).importing_mixin
111+
proxy_class = class << self.__elasticsearch__; self; end
112+
proxy_class.__send__ :include, Elasticsearch::Model::Importing::ClassMethods
113+
proxy_class.__send__ :include, Adapter.from_class(base).importing_mixin
113114

114-
forward :'self.__elasticsearch__', :import unless respond_to?(:import)
115+
forward :'self.__elasticsearch__', :import unless respond_to?(:import)
115116
end
116117
end
117118

0 commit comments

Comments
 (0)