Why is changeset for Paper Trail empty?

1k views Asked by At

I recently upgraded my Ruby to 3.1.2 and Rails to 7.0.3.1.

Somewhere in the changes, one problem I noticed is that my Paper Trails (paper_trails gem) info was now not working, at least with respect to the details.

None of the "changeset" data was available, as so my tests were failing.

2

There are 2 answers

1
Jeremy Lynch On BEST ANSWER

Add this to application.rb:

config.active_record.yaml_column_permitted_classes = [Symbol, Date, Time, ActiveSupport::TimeWithZone, ActiveSupport::TimeZone]

Make sure you restart your server.

2
codenoob On

I put a "byebug" in the view that used the data and looked for what was missing. Apparently my "changeset" data was all missing.

Using this link:

Upgrading to Rails 6.1.6.1 causes Psych::DisallowedClass: Tried to load unspecified class: Symbol

And these:

https://github.com/paper-trail-gem/paper_trail/issues/446

https://github.com/ruby/psych/issues/490

I guessed it was a disallowed class problem, and I ultimately sat on that view breakpoint running

PaperTrail.serializer.load(change_history_by_month.object_changes) (your parameter will be different of course)

until it output the right data. The basic problem apparently was Pysch, and several disallowed classes (for example, "Psych::DisallowedClass Exception: Tried to load unspecified class: BigDecimal"), but fortunately the above will tell you the classes and you can add them to config/application.rb

Very frustrating as it was all quiet, without warnings or errors.

Of course, the classes aren't disallowed for nothing. There may be a security problem here with allowing these classes.