Dynamoid / dynamoid

Ruby ORM for Amazon's DynamoDB.
MIT License
579 stars 195 forks source link

Allow ActiveSupport::HashWithIndifferentAccess of yaml parse #757

Open llpereiras opened 4 months ago

llpereiras commented 4 months ago

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 commented 4 months ago

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.