When attempting to upgrade Avalon to rails 7.0, I ran into an error about modification of frozen arrays, but the real issue was that Rails 6.1 included a major change in ActiveModel::Error turning it into an array of objects instead of a simple hash. The API changed and I had to find an approach that worked for all versions of Rails that ActiveFedora supports. I think the approach I took is a stop gap and that we'll want to rework this using the new API more and possibly rethinking this section entirely. Currently the errors are surfaced on the parent object by composing the child association name with the attribute of the child which has the error. This is problematic because the new ActiveModel::Error implementation checks if error keys are actual attributes on the model object. For example, errors.messages_for("members.foo")` raises `NoMethodError Exception: undefined method `members.foo'.
It appears that there weren't any tests for this part of the code so it slipped by the prior work on supporting rails 7.
When attempting to upgrade Avalon to rails 7.0, I ran into an error about modification of frozen arrays, but the real issue was that Rails 6.1 included a major change in
ActiveModel::Error
turning it into an array of objects instead of a simple hash. The API changed and I had to find an approach that worked for all versions of Rails that ActiveFedora supports. I think the approach I took is a stop gap and that we'll want to rework this using the new API more and possibly rethinking this section entirely. Currently the errors are surfaced on the parent object by composing the child association name with the attribute of the child which has the error. This is problematic because the newActiveModel::Error
implementation checks if error keys are actual attributes on the model object. For example,errors.messages_for("members.foo")` raises `NoMethodError Exception: undefined method `members.foo'
.It appears that there weren't any tests for this part of the code so it slipped by the prior work on supporting rails 7.