Skip to content

Conversation

llpereiras
Copy link

@llpereiras llpereiras commented Jun 6, 2024

The serialized field are stored with ActiveSupport

In my model, I added this:

  field :description, :serialized

image

when I read the record, I received this error:

Psych::DisallowedClass: Tried to load unspecified class: ActiveSupport::HashWithIndifferentAccess

I think, the most of the apps use rails and ActiveSupport, so I think should be a good addiction to add the support of ActiveSupport

For the extra informattion, I doesn't use active record gem.
Because of that, the configuration of active_record like this
config.active_record.use_yaml_unsafe_load
OR
config.active_record.yaml_column_permitted_classes = [ActiveSupport::HashWithIndifferentAccess]
doesn't work for me.

@andrykonchin
Copy link
Member

I agree that it would be convenient to allow serialising such classes like HashWithIndifferentAccess. So the only missing thing in the PR is specs for the new feature. Could you please add them?

But TBH I like mentioned above config option yaml_column_permitted_classes. And use_yaml_unsafe_load could also be useful or at least convenient for developers that are familiar with ActiveRecord. So I am open to adding them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants