Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Dependency on the gems loading order #1094

Open
@r7kamura

Description

@r7kamura

elasticsearch-model only loads the corresponding extensions if thekaminari orwill_paginate has already been loaded when it is loaded.

case
whendefined?(::Kaminari)
Elasticsearch::Model::Response::Response.__send__:include,Elasticsearch::Model::Response::Pagination::Kaminari
whendefined?(::WillPaginate)
Elasticsearch::Model::Response::Response.__send__:include,Elasticsearch::Model::Response::Pagination::WillPaginate
end

In a typical Rails application, gems are usually loaded withBundler.require in config/application.rb, which means that unless those gems are listed in the Gemfile beforeelasticsearch-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 likeActiveSupport.on_load hooks so that it no longer depends on the load order.

For example, theBundler/OrderedGems rule from rubocop-rails, commonly used in Rails development, enforces sorting gems alphabetically in the Gemfile. Following this,elasticsearch-model would appear beforekaminari orwill_paginate, making this issue a frequent occurrence.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp