Avoid reify error on paper_trail

2025-08-02 ruby rails

When I tryed to use paper_trail gem in a new Ruby on Rails project, I have encoutered the error like the below:

Psych::DisallowedClass: Tried to load unspecified class: Date

After discussing in the issue, found 3 ways to solve the problem.

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

  1. Use JSON as the serializer(recommened for new project).
PaperTrail.serializer = PaperTrail::Serializers::JSON
  1. Add permmietd classes for ActiveRecord column.
ActiveRecord.yaml_column_permitted_classes += [Date, Time, String]
  1. Use unsafe_load.
ActiveRecord.use_yaml_unsafe_load = true