Rails 6.1’s ActiveModel Errors Revamp

When our model object contains invalid data, the valid? call would fill up the errors information. Historically this behaved like a hash which maps attribute to error messages. However at Rails 5.0, a separate details hash was added for accessing additional information.The two hashes are supposed to be a one-to-one mapping, but finding one message’s corresponding details is actually a chore. You need to get the index of the message, then use that to access the second hash.
Rails 6.1’s ActiveModel Errors Revamp #ruby #rubydeveloper #rubyonrails #activemodel #errors https://rubyonrails.ba/single/rails-6-1-s-activemodel-errors-revamp

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles