1
0

Unevaluable formulas return nil (instead of throwing error)

Filter formula errors are shown in filter view
This commit is contained in:
cryptogopher
2019-11-09 20:36:10 +01:00
parent 70b6e97b87
commit 67b0cd9b66
8 changed files with 32 additions and 19 deletions

View File

@@ -66,7 +66,14 @@ module BodyTracking
paramed_formula = Ripper.lex(@formula).map do |*, ttype, token|
QUANTITY_TTYPES.include?(ttype) ? "params['#{token}'].to_d" : token
end.join
inputs.map { |i, values| [i, get_binding(values).eval(paramed_formula)] }
inputs.map do |i, values|
begin
[i, get_binding(values).eval(paramed_formula)]
rescue
[i, nil]
end
end
end
private
@@ -82,7 +89,7 @@ module BodyTracking
end
def validate_each(record, attribute, value)
Formula.new(record.project, value, options).validate.each do |message, params|
Formula.new(record.project, value).validate.each do |message, params|
record.errors.add(attribute, message, params)
end
end