Handle Rails 6.1 ActiveModel::Errors changes
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