-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Don't hardcode locale for to_sentence #37047
Don't hardcode locale for to_sentence #37047
Conversation
I'm not sure the locale is needed at all. This isn't an error that we show to users on the frontend and looking through the rest of ActiveRecord we don't directly pass locale into those either. I tracked this change down to 6de8356 and it's clear from other uses of What do you think? |
@eileencodes makes sense to me, I'll make that change! |
9951701
to
63b3617
Compare
FWIW it looks like
to_sentence currently.
|
@eileencodes should I change ☝️ that one too? |
Yup, let's update that one too. |
For example, HasManyThroughSourceAssociationNotFoundError uses to_sentence to create its message, but was hardcoded to use the `en` locale. In cases where this locale did not exist, this caused the exception to be suppressed in favour of an I18n::InvalidLocale exception. This change removes the hardcoded locale, which allows I18n to use its default locale.
63b3617
to
b99c21a
Compare
@eileencodes done! |
Don't hardcode locale for to_sentence
Summary
When a
HasManyThroughSourceAssociationNotFoundError
exception is raised, and there is noen
locale, the user receives aI18n::InvalidLocale: :en is not a valid locale
exception instead which suppresses the actual error.This change just checks for an
en
locale being available and falls back toI18n.default_locale
if it's not.Fixes #37044.