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

Rename I18n::Backend::ActiveRecord::Translation#to_hash to #to_h #133

Merged
merged 1 commit into from
Jun 21, 2022

Conversation

cbeer
Copy link
Contributor

@cbeer cbeer commented Jun 8, 2022

The implicit hash conversion (from #to_hash) causes an unexpected problem in Ruby 2.7.

I18n::Backend::ActiveRecord::Translation.create(locale: 'en', key: 'foo', value: 'bar')

proc = ->(scope = nil, all_queries: nil) { }
proc.call(I18n::Backend::ActiveRecord::Translation)

Traceback (most recent call last):                    
(irb):3:in `block in <main>': unknown keyword: :en (ArgumentError)

Renaming #to_hash seems sufficient to avoid this behavior.

…void problems with ruby2_keywords and Rails 7
@timfjord
Copy link
Collaborator

timfjord commented Jun 9, 2022

Hi @cbeer

Could you please share a full traceback, because the error message looks a bit weird and I am not sure that renaming to_hash has something to do with it

@cbeer
Copy link
Contributor Author

cbeer commented Jun 9, 2022

That's it, nothing else. It's definitely weird, but something to do with automatic conversion from a hash to keyword arguments. There's some related bug reports in Ruby: https://bugs.ruby-lang.org/issues/12821

@timfjord timfjord merged commit cfc7afc into svenfuchs:master Jun 21, 2022
@timfjord
Copy link
Collaborator

Merged! Thanks for the contribution @cbeer

@cbeer cbeer deleted the rails7-to-hash branch June 21, 2022 16:04
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