Commit eca701e
authored
Remove checks on conditions in the 'ms_must_reindex?' method
This commit removes the checks on the meilisearch conditions options `:if` and `:unless` in the `ms_must_reindex?` method as they are incorrectly used.
## Low level reason
[Indeed the README documents an example on how to avoid reindexing when an `if:` condition is defined (e.g. `if: :published?`)](https://github.com/meilisearch/meilisearch-rails/tree/main?tab=readme-ov-file#conditional-indexing). However the documented way doesn't work: Indeed, one would need to define a method `#will_save_change_to_published??` (note the two question marks) to be able to prevent reindexing. However ruby doesn't allow such a method name (with double trailing question marks).
## Higher level reason
In a high level vision, the `if:` and `unless:` conditions are used as “constraints” when the lib will try to index a resource in many different places of the code by executing `Utilities.indexable?(...)` before trying to index, those those conditions are sufficient to “enable” or “disable” the indexation of the lib, no matter what attributes change on the record.
Why would the “must_reindex” logic try to check those conditions? I admit I didn't understand and believe this code is obsolete.
What do you folks think?1 parent 16e4d4b commit eca701e
1 file changed
+0
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
765 | 765 | | |
766 | 766 | | |
767 | 767 | | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | | - | |
780 | | - | |
781 | 768 | | |
782 | 769 | | |
783 | 770 | | |
| |||
0 commit comments