-
Notifications
You must be signed in to change notification settings - Fork 82
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
Fallback local for sort if translated attribute is nil #396
Comments
translates :name, type: :string, fallbacks_generator: lambda {
I18n.available_locales.each_with_object({}) do |locale, memo|
memo[locale] = :'en-US'
end
}, locale_accessors: true
|
Mental note: v1.0 should warn or raise on options that are not consumed by any plugin or backend. |
This is similar to #51, but it's tricky and not really a priority right now, sorry. I'm going to close it because realistically it's not going to happen (anytime soon, anyway). |
@shioyama thanks for the clarification on |
If a translated attribute is nil in the current
Mobility.locale
, ideally the attribute value in fallback language would be used as a substitute in theorder by
clause.Context
I am currently using Mobility with Postgres (with a Table backend).
Expected Behavior
This is an example of the expected behaviour
The data is seeded without a value in Spanish for
category1
The expected output uses the English fallback
name
for Mouse as the Spanishname
value is missing and English has been defined as the fallback locale.Actual Behavior
The
order
attribute appears to resolve thename
tonil
when sorting. This movescategory1
to the bottom of the array.Possible Fix
It might be possible to fallback the locale using
COALESCE
.The text was updated successfully, but these errors were encountered: