-
Notifications
You must be signed in to change notification settings - Fork 807
Description
elasticsearch-model
only loads the corresponding extensions if the kaminari
or will_paginate
has already been loaded when it is loaded.
elasticsearch-rails/elasticsearch-model/lib/elasticsearch/model.rb
Lines 57 to 62 in 41f4291
In a typical Rails application, gems are usually loaded with Bundler.require
in config/application.rb, which means that unless those gems are listed in the Gemfile before elasticsearch-model
, it won’t work as intended.
The fact that behavior changes depending on the order of gems makes it very confusing and prone to misunderstandings. I think it would be much better to improve it by using mechanisms like ActiveSupport.on_load
hooks so that it no longer depends on the load order.
For example, the Bundler/OrderedGems
rule from rubocop-rails, commonly used in Rails development, enforces sorting gems alphabetically in the Gemfile. Following this, elasticsearch-model
would appear before kaminari
or will_paginate
, making this issue a frequent occurrence.