Skip to content

Handle Rails 6.1 ActiveModel::Errors changes

Igor Drozdov requested to merge cherry-pick-b5ecc309 into master

What does this MR do?

Modal errors as objects are introduced: https://github.com/rails/rails/pull/32313 (great contribution by @lulalala 💪)

model.errors.first returns ActiveModel::Error object that's why model.errors.first[1] doesn't work in Rails 6.1

We need a way that works both for 6.1 and 6.0 in order to introduce changes gradually: model.errors[:key] works for both versions.

Even though treating errors as a hash is deprecated it works so we can introduce the changes in 6.0 and then fix the deprecations when we're on 6.1.

Related issue: #225874 (closed)

Edited by Igor Drozdov

Merge request reports