Using mongoid 7.3.1 and ruby 3.0.2 the following causes ArgumentError exceptions to be raised:
class User include Mongoid::Documentfield :name, type: String has_many :stuff, dependent: :restrict_with_error def foo(my_keyword_arg: 'foo') puts "#{my_keyword_arg}!" end end class Stuff include Mongoid::Documentfield :foo, type: String belongs_to :user def foo_my_user user.foo(my_keyword_arg: 'bar') end end user = User.create!(name: 'my user') stuff = Stuff.create!(foo: 'bar', user: user) stuff.user.foo # => outputs 'foo!' as expected stuff.user.foo(my_keyword_arg: 'baz') # => raises ArgumentError stuff.foo_my_user # => raises ArgumentError
The cause seems to be that Association::Proxy#method_missing is not handling keyword arguments correctly; instead of
```def method_missing(name, *args, &block)```
you'll probably want
```def method_missing(name, *args, **kwargs, &block)```
`#respond_to_missing` below will probably need that treatment as well.