Symbol
is also not allowed per default. Therefore, you need to add Symbol
to the permitted_classes
too when loading a file:
hash = YAML.load_file(
some_file_name,
permitted_classes: [Matrix, OpenStruct, Symbol]
)
See the list of default permitted_classes
in Psych.
Or, when using in Ruby on Rails, you can configure what classes Rails should permit globally when using YAML files in your config/application.rb
:
config.active_record.yaml_column_permitted_classes += [Matrix, OpenStruct, Symbol]
Note that for internal YAML parsing in Ruby on Rails Symbol
is already the default for active_record.yaml_column_permitted_classes
.