[Feature Proposal] ActiveModel::Errors return errors with object's attributes

Problem Statement

Over the past few months, I needed to create multiple bulk endpoints. When this process fails, I need to return the instances error messages alongside the object’s attributes.

I searched on ActiveModel::Errors and I didn’t find a method that could do this.

I made an easy workaround:

failed_instances.each do |obj|
  { attributes: obj.attributes, errors: obj.errors }


I think this is a common problem that could help in some cases.

This can be added to ActiveModel::Errors named like #object_attributes_with_errors

I want feedback if this is viable and if it’s something y’all want to include to rails.

I’ll gladly submit a PR for this :raised_hand:

Wouldn’t it be better to have this as a part of your specific way of serializing your objects? It seems straight forward enough.