We recently updated a client's application from Rails 4 to rails 5. However, after running the test suite the following issue appeared whilst trying to create an object:
Failure/Error:
@ens_response = EnsResponse.create!(
edi_request_body: @response.edi_request_body,
edi_body: @response.edi_data,
reject_reason: @response.attributes.try(:[], :reject_reason).try(:[], :text),
response_attributes: @response.attributes
)
Psych::DisallowedClass:
Tried to load unspecified class: Policy
Where Policy is a model in our app/models/
folder.
We tried changing the loading of the YAML to the following:
@service_hash ||= YAML.load_file(
Rails.root.join('config', 'mcp_services.yml'),
permitted_classes: [Policy ],
aliases: true
)[Rails.env]
But it was to no avail.
We also tried changing the application.rb
file to use the following line:
config.active_record.yaml_column_permitted_classes = [
Symbol,
ActiveSupport::HashWithIndifferentAccess,
ActionController::Parameters
but just got the error:
Failure/Error: require File.expand_path("../../config/environment", __FILE__)
NoMethodError:
undefined method `yaml_column_permitted_classes=' for ActiveRecord::Base:Class
Any idea what might be causing this issue?
Local psych is at version psych (default: 3.0.2)
and rails is on gem 'rails', '5.2.8'
Thanks in advance! :)