Skip to content
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

Fix will_paginate crash when Meilisearch disabled #383

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ellnix
Copy link
Collaborator

@ellnix ellnix commented Jan 13, 2025

Pull Request

Related issue

Fixes #382

I added a utility method to make the check for NullObject clearer than just testing for nil?. I'm still not a fan of the solution, I think it would be best if it was behind a Meilisearch::Rails.active? if statement.

Please let me know what you think.

@ellnix ellnix added the bug Something isn't working label Jan 13, 2025
Copy link

codecov bot commented Jan 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.16%. Comparing base (d0a6f1a) to head (e9cf005).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #383      +/-   ##
==========================================
+ Coverage   88.96%   89.16%   +0.20%     
==========================================
  Files          13       13              
  Lines         761      766       +5     
==========================================
+ Hits          677      683       +6     
+ Misses         84       83       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

When Meilisearch is disabled, NullObject is passed to will_paginate when
it expects integers.
@ellnix ellnix force-pushed the will-paginate-disabled-error branch from 26e05b8 to e9cf005 Compare January 13, 2025 20:05
@ellnix ellnix marked this pull request as ready for review January 13, 2025 20:05
ellnix added a commit to ellnix/meilisearch-rails that referenced this pull request Jan 14, 2025
Using Meilisearch::Rails.active? as an alternative to checking that the
objects being replaced are actually.

For an alternative solution see meilisearch#383

The advantage of this approach is that NullObject remains opaque, and
the logic is much easier to follow (in my opinion).
ellnix added a commit to ellnix/meilisearch-rails that referenced this pull request Jan 14, 2025
Using Meilisearch::Rails.active? as an alternative to checking that the
objects being replaced are actually NullObject.

For an alternative solution see meilisearch#383

The advantage of this approach is that NullObject remains opaque and
requires no special treatment, and the logic is much easier to follow
(in my opinion).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when paginating with will_paginate and Meilisearch is disabled
1 participant