Fix displaying of discarded variants in admin #4148
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
After this, discarded variants are not displayable anymore because
Discard#discarded
scope now operates onkept
scope and finds no result if not prepended with a larger scope, as suggested here.This prevents the "deleted variants" filter from being displayed in the variants list on the admin panel.
This PR provides a quick fix for displaying the "deleted variants" filter again in the admin variants, which allows to display the deleted variants again.
Two alternative solutions that I considered, with the help of @spaghetticode:
discarded
scope: this implementation would be very dependent on the soft deletion gem in-use, because (as far as I know) there is no way to call thesuper
scope from its override. It would have resulted in something likescope :discarded, -> { with_discarded.where.not(deleted_at: nil) }
.So I thought that the solution I'm proposing was more reasonable, let me know your thoughts if you disagree or I'm missing something.
Checklist: