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 #rails #rubyonrails #bosnia #programming #tutorials #rubydeveloper #railsdeveloper

Nezir Zahirovic

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

related articles