Add permalink history for taxon on friendly-id#7
Merged
Conversation
29f6523 to
69edb57
Compare
64d7be7 to
5d070ab
Compare
5d070ab to
8fe563b
Compare
8fe563b to
70da3c7
Compare
70da3c7 to
8722086
Compare
- Introduced FriendlyId to the Taxon model to enable slug history tracking. - Replaced before_create and before_update callbacks with a before_save callback for better slug management. - Implemented a custom should_generate_new_friendly_id? method to control when a new slug is generated, specifically when the permalink changes. - Added a custom normalize_friendly_id method to ensure proper slug formatting for nested taxons. - Included a test to verify that the history of permalinks is correctly stored when a taxon's permalink is updated, ensuring both initial and updated slugs are retained. This change enhances the flexibility and reliability of handling slugs for taxons.
8722086 to
5618cc6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
[WIP] Open Questions
This PR aligns URL handling of taxons with products.
Open questions:
Related Issues, PRs and Discussions
Description
This PR introduces
FriendlyIdto theTaxonmodel to store the history of permalinks (slugs) and provides a more flexible approach to handling slugs for taxons.Changes:
Taxon Model:
FriendlyIdto theTaxonmodel, enabling it to generate and store slug history.before_savecallback is used to set the permalink instead ofbefore_createandbefore_update, allowing for better slug management.should_generate_new_friendly_id?to control when a new friendly ID should be generated, specifically when the permalink changes.normalize_friendly_idmethod to adjust how slugs are generated, especially for nested taxons, ensuring proper formatting of the slug.Test:
Motivation
This update enhances the management of taxon slugs by allowing historical tracking of slugs. This is particularly useful for SEO purposes and for maintaining accessibility of the resource if URLs change over time.
Note
The starter frontend PR is dependent for this change starter frontend PR