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

Generate all translated slugs when model is saved #12

Merged
merged 3 commits into from Aug 5, 2018

Conversation

shioyama
Copy link
Owner

@shioyama shioyama commented Aug 4, 2018

Added a test for #10

@shioyama
Copy link
Owner Author

shioyama commented Aug 5, 2018

@n-rodriguez this should fix #10, can you just check it works for you? Then I'll merge and deploy it.

@n-rodriguez
Copy link
Contributor

@shioyama I've just checked and it partially works. It still needs patch on should_generate_new_friendly_id? method.

@shioyama
Copy link
Owner Author

shioyama commented Aug 5, 2018

@shioyama I've just checked and it partially works. It still needs patch on should_generate_new_friendly_id? method.

Ah I can fix that too. Hold on I'll push another commit.

@n-rodriguez
Copy link
Contributor

Ah I can fix that too. Hold on I'll push another commit.

Great!

@shioyama shioyama force-pushed the translated_slugs_other_locale branch 2 times, most recently from e56a883 to 51d6b96 Compare August 5, 2018 02:12
@shioyama
Copy link
Owner Author

shioyama commented Aug 5, 2018

It still needs patch on should_generate_new_friendly_id? method.

Actually I'm not sure the issue with this one, can you clarify?

@n-rodriguez
Copy link
Contributor

I was referring to #10 (comment)
To make the first test pass you need to uncomment should_generate_new_friendly_id? and translation_for patched methods.
To make the second test pass you need to uncomment the set_slug patched method.

@shioyama
Copy link
Owner Author

shioyama commented Aug 5, 2018

Ah so the problem seems to be fallbacks...

@n-rodriguez
Copy link
Contributor

Ah so the problem seems to be fallbacks...

Yes

@shioyama
Copy link
Owner Author

shioyama commented Aug 5, 2018

Ok I added 9cb5194 which seems to fix the specs. The problem was that should_generate_new_friendly_id? was calling the slug attribute method, which was falling back so it seemed like it didn't need to regenerate the slug. By instead calling slug(locale: Mobility.locale) Mobility ignores fallbacks, which fixes the issues.

@n-rodriguez
Copy link
Contributor

Awesome! It works!

@shioyama shioyama merged commit 9cb5194 into master Aug 5, 2018
@shioyama
Copy link
Owner Author

shioyama commented Aug 5, 2018

This has been released as 0.5.4. Thanks for your help!

@n-rodriguez
Copy link
Contributor

This has been released as 0.5.4. Thanks for your help!

You're welcome! Thanks for this gems!

@shioyama shioyama deleted the translated_slugs_other_locale branch April 11, 2020 01:54
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.

None yet

2 participants