cloudflare icon indicating copy to clipboard operation
cloudflare copied to clipboard

Not compatible with ruby 3.X

Open julienchabanon opened this issue 3 years ago • 7 comments

Method arguments using **options is not valid in ruby 3.0 and as a result, we now get an error saying it expect 3 arguments instead of 4.

https://github.com/socketry/cloudflare/blob/master/lib/cloudflare/dns.rb#L78

More on this here: https://bugs.ruby-lang.org/issues/14183

zone.dns_records.create *** ArgumentError Exception: wrong number of arguments (given 0, expected 3)

ruby: 3.0.2 gem version 4.3.0

julienchabanon avatar Nov 04 '21 17:11 julienchabanon

please help.

f-asa avatar Nov 04 '21 18:11 f-asa

zone.dns_records.create
*** ArgumentError Exception: wrong number of arguments (given 0, expected 3)

Well, you are supplying zero arguments, and there are 3 non-optional arguments.

ioquatix avatar Nov 05 '21 07:11 ioquatix

@ioquatix yes I did that in purpose in rails console to show the number of expected params when using ruby 3.0. It is supposed to be 4.

I already have a fix, I will do a PR soon.

julienchabanon avatar Nov 05 '21 16:11 julienchabanon

We just ran into this, so far all our attempts return the same error – do you mind sharing your fix @julienchabanon

sailing avatar Sep 06 '23 19:09 sailing

@sailing

Assuming options is a hash, instead of doing something like: zone.dns_records.create('A', 'batman', '1.2.3.4', options)

You should now be doing something like: zone.dns_records.create('A', 'batman', '1.2.3.4', **options)

julienchabanon avatar Sep 06 '23 19:09 julienchabanon

Thanks @julienchabanon!

sailing avatar Sep 06 '23 20:09 sailing

Sorry, I'll take a look at this code and fix it.

ioquatix avatar Sep 07 '23 00:09 ioquatix