-
Notifications
You must be signed in to change notification settings - Fork 801
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
Add compatibility with Ruby 3 #992
Add compatibility with Ruby 3 #992
Conversation
💚 CLA has been signed |
I have now read and signed the contributor agreement. |
I've updated the implementation to work on Ruby 2.4 through 3.0, based on this ruby-core blog post, which should keep this change backwards-compatible. |
when the proxy fails to forward keywoard arguments, the error for methods that only accept keyword arguments looks like this: ArgumentError: wrong number of arguments (given 1, expected 0)
this resolves a bug with Rails 6.1 on Ruby 3, where keyword arguments are not forwarded and this causes an ArgumentError
since Ruby 1.9.2, about 12 years ago, you're supposed to define respond_to_missing? if you also define method_missing. there's more explanation in this blog post by a ruby committer in 2010: http://blog.marc-andre.ca/2010/11/15/methodmissing-politely/
d35acf3
to
d9c062c
Compare
Whoops, I must have accidentally deleted the first line when I opened the file and not noticed. Fixed. |
Any outlook on merging this? |
@picandocodigo can you release a new version that includes this fix? |
I also need this fix ! Please can you release a new version? |
I upvote for releasing |
Version 7.2.1 has been released with these changes. |
Would it be possible to add this patch to the 6.x version? We are using Elasticsearch 6 and would love to have Ruby 3 support in 6.1.2 too. Right now we have to monkeypatch. |
|
Since Ruby 3 changed the way keyword arguments work, Rails now only accepts keyword arguments for
find_in_batches
. Unfortunately, themethod_missing
implementation onElasticsearch::Model::Proxy
doesn't proxy keyword arguments, so Rails now explodes. The error is triggered by callingModel.import
, and looks something like this:The fix is to forward not just positional arguments, but also keyword arguments. This PR adds a test (failing before the patch), and a patch to forward keyword arguments.
Fixes #989, #977.