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 History + SequentiallySlugged + Scope issues #877

Merged
merged 3 commits into from
Aug 10, 2018
Merged

fix History + SequentiallySlugged + Scope issues #877

merged 3 commits into from
Aug 10, 2018

Conversation

kshnurov
Copy link
Contributor

SequentiallySlugged with History doesn't look into previously used slugs, which can result in a wrong last_sequence_number and failure.

@kshnurov
Copy link
Contributor Author

@norman @parndt could you please look into this?

base_class = Slug
else
base_class = self.class.base_class
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you extract this into a method base_class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parndt done

@@ -7,11 +7,17 @@ def self.setup(model_class)
def resolve_friendly_id_conflict(candidate_slugs)
candidate = candidate_slugs.first
return if candidate.nil?
SequentialSlugCalculator.new(scope_for_slug_generator,
scope = scope_for_slug_generator
Copy link
Collaborator

@parndt parndt Jul 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could probably go back to being used inline?

SequentialSlugCalculator.new(scope_for_slug_generator,

because it doesn't get re-used so it doesn't appear to need to be a variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parndt done

@kshnurov
Copy link
Contributor Author

kshnurov commented Aug 9, 2018

This have been running for 3 weeks in production, the only problem I've found is that Scoped#scope_for_slug_generator overrides History#scope_for_slug_generator in some cases.

I have History added inside FriendlyId.defaults and Scoped added inside a model, this could be the reason. Can't reproduce that in a test, but this fixes the problem.

@parndt parndt merged commit 9cb316a into norman:master Aug 10, 2018
@parndt
Copy link
Collaborator

parndt commented Aug 10, 2018

Thanks a lot @kshnurov 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants