diff --git a/lib/attr_encrypted/adapters/active_record.rb b/lib/attr_encrypted/adapters/active_record.rb index 3111cbd5..6f25b8fb 100644 --- a/lib/attr_encrypted/adapters/active_record.rb +++ b/lib/attr_encrypted/adapters/active_record.rb @@ -29,8 +29,8 @@ class << self def perform_attribute_assignment(method, new_attributes, *args) return if new_attributes.blank? - send method, new_attributes.reject { |k, _| self.class.encrypted_attributes.key?(k.to_sym) }, *args - send method, new_attributes.reject { |k, _| !self.class.encrypted_attributes.key?(k.to_sym) }, *args + send method, new_attributes.reject { |k, _| self&.class&.encrypted_attributes&.key?(k.to_sym) }, *args + send method, new_attributes.reject { |k, _| !self&.class&.encrypted_attributes&.key?(k.to_sym) }, *args end private :perform_attribute_assignment