nesquena / rabl

General ruby templating with json, bson, xml, plist and msgpack support
http://blog.codepath.com/2011/06/27/building-a-platform-api-on-rails/
MIT License
3.64k stars 333 forks source link

Fix `ArgumentError` when block given with keyword arguments #757

Closed kyoshidajp closed 2 years ago

kyoshidajp commented 2 years ago

On Ruby 3.0 or later with Rails, if the following template exists

node(:field) do
  l(Time.now, format: :min)
end

then, the following error raised.

ArgumentError in Hoge::Fuga#index
Showing /Rails.root/app/views/hoge/fuga/index.json.rabl where line #2 raised:

wrong number of arguments (given 2, expected 1)

This is due to a breaking change in the keyword argument in Ruby 3.0.

nesquena commented 2 years ago

Is this expected to work on Ruby 2.X as well?

kyoshidajp commented 2 years ago

@nesquena Yes. It works as expected on Ruby 2.6.6 and 2.7.4.

The modified code was verified by working with the above version. The context when a breakpoint is placed in the method_missing method is as follows.

rabl-debug

In the specs, I need to change activerecord version as 6.1.6.1, then run successfully on Ruby 2.6.6, 2.7.4 and 3.1.2.

nesquena commented 2 years ago

Thanks!