In models that use attr_readonly, the specified attributes aren't modifiable after resource create, but the audit is generated regardless of the configuration and order (it registers regardless of whether attr_readonly comes before or after audited)
Example:
class User < ApplicationRecord
attr_readonly :email
audited
end
# All rigth, this should register
user = User.create(email: "abc@example.com")
user.email # => "abc@example.com"
audit = user.audits.last
audit.action # => "create"
audit.audited_changes # => {"email"=>[nil, "abc@example.com"]}
# Bad, this shouldn't register
user.update(email: "new@example.com")
user.email # => "abc@example.com"
audit = user.audits.last
audit.action # => "update"
audit.audited_changes # => {"email"=>["abc@example.com", "new@example.com"]}
In models that use
attr_readonly
, the specified attributes aren't modifiable after resource create, but the audit is generated regardless of the configuration and order (it registers regardless of whetherattr_readonly
comes before or afteraudited
)Example: