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

V 5.4.0 breaking change to Object.friendly.find method #950

Closed
ccasabona opened this issue Aug 14, 2020 · 4 comments · Fixed by #951
Closed

V 5.4.0 breaking change to Object.friendly.find method #950

ccasabona opened this issue Aug 14, 2020 · 4 comments · Fixed by #951

Comments

@ccasabona
Copy link

Before merge of 787, one could pass a mixed-case slug to friendly.find as such:

Customer.friendly.find(params[:id])

We don't use the customer name for the slug; rather we used SecureRandom.urlsafe_base64 to generate a random string. Thus the slugs for our customers contain a mix of upper and lowercase characters. At this point we have thousands of customers with mixed-case slugs in our databases.

Because this is breaking (for us) some kind of opt-in to the new behavior would seem to make the most sense.

@parndt
Copy link
Collaborator

parndt commented Aug 16, 2020

I'm pretty keen to revert this change and make it opt-in by default. I'll open a PR with the revert to start things off.

@ansonhoyt
Copy link

ansonhoyt commented Aug 18, 2020

Since this is a breaking change, and defaulting to opt-in, should this new default behavior go in a 6.0.0 release (semver)?

Edit
Woops, after re-reading #951, I see I'm mistaken. Looks like the breaking id.downcase change in 5.4.0 will be reverted. This new ability will be available for those who need it by overriding the new parse_friendly_id method.

My bad! This will really be "opt-in", and wouldn't be a breaking change.

@ethicalhack3r
Copy link

This also broke our slugs on wpvulndb.com, reverting back to version 5.3.0 fixed the issue.

gem 'friendly_id', '5.3.0' in Gemfile

@coopeu
Copy link

coopeu commented Sep 3, 2020

Me too! updating to 5.4.0 on MilRevolts.life
Thanks ethicalhack3r

mejackreed added a commit to projectblacklight/spotlight that referenced this issue Sep 4, 2020
jkeck pushed a commit to projectblacklight/spotlight that referenced this issue Sep 4, 2020
parndt added a commit that referenced this issue Nov 10, 2020
In #787 we merged a change which found slugs by `id.downcase` by
default, but this has understandably caused issues for other users of
FriendlyId who don't want to do this.

This reverts that change and introduces a new method, 
`parse_friendly_id`, which can be overridden similar to 
`normalize_friendly_id`.  

Instead of being used for slug generation, `parse_friendly_id` is used
for parsing incoming slugs.

Fixes #950
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 a pull request may close this issue.

5 participants