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 :default option in Translate.attribute method #1218

Merged
merged 1 commit into from
Mar 31, 2021

Conversation

coreyaus
Copy link
Contributor

At the moment it's possible to pass a default translation (or translation key) to the Ransack::Translate.attribute method, however it is never actually accessed given the existing fallback using interpolated attribute/predicate names. Those interpolated strings are either "%{attributes}" or "%{attributes} %{predicate}", which never return nil. Any value passed to options[:default] is added to the end of the defaults array (after those never-nil interpolated strings), and as a result the default that is specifically supplied by the user of the gem is never actually accessed or output. This pull request is aimed at resolving that (ever-so-slight) bug

At the moment it's possible to pass a default translation (or translation key) to the Ransack::Translate.attribute method, however it is never actually accessed given the existing fallback using interpolated attribute/predicate names. Those interpolated strings are either "%{attributes}" or "%{attributes} %{predicate}", which never return nil. Any value passed to options[:default] is added to the end of the defaults array (after those never-nil interpolated strings), and as a result the default that is specifically supplied by the user of the gem is never actually accessed or output. This pull request is aimed at resolving that (ever-so-slight) bug
@scarroll32 scarroll32 merged commit 0bd4afe into activerecord-hackery:master Mar 31, 2021
@scarroll32
Copy link
Member

Looks good, thank you @coreyaus

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