You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rails 7.1 modifies raise_on_assign_to_attr_readonly link to be enabled by default. In the past, the code would silently carry on. I'm now fixing our code base to no longer write to a read_only attribute.
Reify sets a model's readonly attribute here:
if model.has_attribute?(k)
model[k.to_sym] = v
Check the following boxes:
This is not a usage question, this is a bug report
This bug can be reproduced with the script I provide below
This bug can be reproduced in the latest release of the paper_trail gem
Bug reports must use the following template:
# frozen_string_literal: true# Use this template to report PaperTrail bugs.# Please include only the minimum code necessary to reproduce your issue.require"bundler/inline"# STEP ONE: What versions are you using?gemfile(true)doruby"3.3.1"source"https://rubygems.org"gem"activerecord","7.1.3.2"gem"minitest","5.21.2"gem"paper_trail","15.1.0",require: falsegem"sqlite3","1.5"endrequire"active_record"require"minitest/autorun"require"logger"ActiveRecord.raise_on_assign_to_attr_readonly=trueActiveRecord.use_yaml_unsafe_load=true# Please use sqlite for your bug reports, if possible.ActiveRecord::Base.establish_connection(adapter: "sqlite3",database: ":memory:")ActiveRecord::Base.logger=nilActiveRecord::Schema.definedo# STEP TWO: Define your tables here.create_table:users,force: truedo |t|
t.text:first_name,null: falset.timestampsnull: falseendcreate_table:versionsdo |t|
t.string:item_type,null: falset.integer:item_id,null: falset.string:event,null: falset.string:whodunnitt.text:object,limit: 1_073_741_823t.text:object_changes,limit: 1_073_741_823t.datetime:created_atendadd_index:versions,%i[item_typeitem_id]endActiveRecord::Base.logger=Logger.new(STDOUT)require"paper_trail"# STEP FOUR: Define your AR models here.classUser < ActiveRecord::Basehas_paper_trailattr_readonly:idend# STEP FIVE: Please write a test that demonstrates your issue.classBugTest < ActiveSupport::TestCasedeftest_1user=User.create(first_name: "Jane")user.update!first_name: "Janet"versions=user.versionsold_user=versions.last.reifyendend# STEP SIX: Run this script using `ruby my_bug_report.rb`
Here is the output that I see....
BugTest#test_1:
ActiveRecord::ReadonlyAttributeError: id
The text was updated successfully, but these errors were encountered:
Rails 7.1 modifies raise_on_assign_to_attr_readonly link to be enabled by default. In the past, the code would silently carry on. I'm now fixing our code base to no longer write to a read_only attribute.
Reify sets a model's readonly attribute here:
Check the following boxes:
paper_trail
gemBug reports must use the following template:
Here is the output that I see....
The text was updated successfully, but these errors were encountered: