-
Notifications
You must be signed in to change notification settings - Fork 49
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
Unable to use id
in ActiveModel validations since reform-rails 0.2.4
#103
Comments
Hi Vesa, thanks for the detailed report. I feel like we had a similar discussion about delegation here #101 could you verify? |
@valscion IMO, the validation seems correct here based on the test case because it says that |
Thanks, I'll take a look!
I am trying to validate the incoming form values, not what's in the existing record. It used to work in the past but now property :id, virtual: true |
That is indeed a good point, @valscion. I wonder if that maybe is a bug in Reform itself? |
Yeah I've added a debug entry point inside the validates :_destroy, presence: true, if: -> { id } and in I did check out #101 but that seems slightly different to what we have — and their patch that they added (changing the populator) also doesn't apply for us because we are already doing the "find the item" part of the populator the same way as their patch did: collection.find { |itm| itm.model.id.to_s == fragment[:id].to_s } |
I dug a bit deeper and noticed that the
|
Why can't every OSS bug hunter be like you? 💚 I have a suspicion, could you figure out which |
Based on the output of
That's also what we have in |
So we're using the same version of |
I don't really understand your question? We do have only one version of |
Of course you do 😆 my questions was whether across the |
Oh yes, both |
Ok that's good, I was dreading a bug inside |
Cool! Let me know if I can help debug this any further |
Well you could look into the form object and figure out if, after instantiation, it read the |
What Thanks for this great reporting style, this is so much more helpful then "it simply doesn't work"! Appreciate it! ☕ |
That's visible in the output of
That is, we are using |
Please try |
Looks like EDIT: Looks like all issues we had are fixed now indeed! 👏 |
Looks like 0ba0ac0 did indeed fix our issues and all would seem to work with that commit in a version of |
Thanks again for your debugging and reporting, I wish we had more people like you! 💪 |
Hi!
We are struggling to update
reform-rails
from 0.2.3 to 0.2.5 (we also had this same struggle withreform-rails
version 0.2.4).The problem seems to stem from us having this kind of validation:
And we have this kind of validation call:
With
reform-rails
0.2.4 and 0.2.5, we get a validation error saying that_destroy
can't be blank while with 0.2.3 we don't get that.The change is that in
reform-rails
0.2.3, the value ofid
in theif: -> { id }
lambda was read from the parameters passed toform.validate
while in 0.2.5, the value ofid
is read from theform.model
. I think the problem is somehow caused by 294de5f and #100 but I don't really understand why.Is it possible that with the old
Uber::Delegates
, theid
delegation was somehow different than how it is now with Rails provideddelegate
method?Here's the full source code for our form
And here's how we have a unit test for it:
Back in
reform-rails
0.2.3, this code didn't have errors but now with 0.2.5, we get an error:The text was updated successfully, but these errors were encountered: