Fix structured error creation if attributes don't match; write match status to database

This commit is contained in:
Maximilian Grundke
2017-07-19 15:46:19 +02:00
parent 7ba245920c
commit 5d6158f95a
3 changed files with 17 additions and 3 deletions

View File

@ -3,7 +3,15 @@ class StructuredErrorAttribute < ActiveRecord::Base
belongs_to :error_template_attribute
def self.create_from_template(attribute, structured_error, message_buffer)
value = message_buffer.match(attribute.regex).captures[0]
self.create(structured_error: structured_error, error_template_attribute: attribute, value: value)
match = false
value = nil
result = message_buffer.match(attribute.regex)
if result != nil
match = true
if result.captures.size > 0
value = result.captures[0]
end
end
self.create(structured_error: structured_error, error_template_attribute: attribute, value: value, match: match)
end
end