Skip to content

Fix deprecation warning in ActiveModel::Errors

Tan Le requested to merge tancnle-fix-rails-errors-deprecation-warning into master

What does this MR do?

Fix deprecation warning in ActiveModel::Errors.

From the deprecation warning:

DEPRECATION WARNING: Enumerating ActiveModel::Errors as a hash has been deprecated. In Rails 6.1, errors is an array of Error objects, therefore it should be accessed by a block with a single block parameter like this:

person.errors.each do |error|
  attribute = error.attribute
  message = error.message
end

You are passing a block expecting two parameters, so the old hash behavior is simulated. As this is deprecated, this will result in an ArgumentError in Rails 6.2. (called from map at /Users/tanle/Code/gitlab/gitlab-development-kit/gitlab/app/helpers/form_helper.rb:13)

🎀 Bonuses

Steps to reproduce

Run the following spec and observe the above deprecation warning.

bundle exec rspec --format documentation gitlab/spec/helpers/form_helper_spec.rb

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Edited by Tan Le

Merge request reports

Loading