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
Can't pass arguments on events with bangs in Ruby 3.0 #834
Comments
Can validate that this is happening on my application: Rails 6.0.6.1 request.accept! # => ArgumentError: wrong number of arguments (given 1, expected 0)
request.accept # => succeeds |
I'm guessing the problem is somewhere between
and
This is made complicated by the changes in args around ruby 3. In the lower code (ruby 3.2 in my case), args is an array with one hash in it. That's probably not what's wanted. Getting that to work for ruby 2.x and 3.x may involve something like |
Ah - it looks like maybe this is fixed in https://github.com/aasm/aasm/tree/add_ruby_3.2_in_github_workflows Looks like that was only a partial fix. |
@kwerle is there a PR for that? I feel the proposed solution is a bit hacky, and also resolves the problem where it blows, not where it originates. The better solution would be to separate the keyword arguments in the |
I found that location by stepping into my code where it was failing. I certainly didn't dig into the AASM code to figure out the right fix. It seems likely that my research could be useful for writing a failing test if nothing else. This issue will block my company from doing a ruby upgrade - which is not a priority for us this quarter. It will become a priority in a couple of months. I'm kind of hoping that it'll be fixed and pushed by then :-) |
@kwerle we're in the same situation, and we might be taking a stab at it soon. |
@kwerle the fix you mentioned is present on 5.5.0. Also, aasm is currently running with ruby 3.0 and rails 6.1 (not 6.0 yet). This example seems to implement the situations that both you and @that-jill discussed, and it seems to pass under all conditions. Can you create a failing spec? |
I'm on an M1 mac and do all my dev work in docker containers. I have not been able to get the aasm test environment up and running so I don't believe I will be able to write a good test. If nobody else tackles this before we really need it, I'll provide a monkey patch that addresses the issue - probably later this quarter. |
I forgot to link the example I believe represents your problem now, and is passing on main. aasm/spec/unit/event_multiple_spec.rb Line 21 in ed88361
Do you agree that it's the same case? If you don't, we could work together to get a failing spec and I can take care of fixing it. |
I'm starting to dig into this, and the first broken spot I see is we have:
It looks like in ruby 3.2 and aasm 5.5.0 |
Ah - instead it is being passes as a hash: |
For those following with interest - I think I've given enough detail to formulate a reasonable test in #834 (comment) . I will not be pursuing this further - our workaround is to simply accept the hash and use that. |
We have the same problem here. Has anyone found a way to fix it? |
I'm working on upgrading an application from Rails 5.2 to latest.
Currently running:
rails 6.1
ruby 3.0
aasm 5.5 (I tried 5.4 too, same results)
When I try to call events with bangs, I get an ArgumentError
wrong number of arguments (given 1, expected 0)
call
With Ruby 2.7 the ArgumentError is not raised
The text was updated successfully, but these errors were encountered: