Displaying errors for uncomputable formulas in nutrients view
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
module BodyTrackersHelper
|
||||
def format_value(value)
|
||||
amount, unitname = value
|
||||
amount.nil? ? '-' : "#{amount} [#{unitname || '-'}]"
|
||||
case
|
||||
when amount.nil?
|
||||
'-'
|
||||
when amount.nan?
|
||||
'?'
|
||||
else
|
||||
"#{amount} [#{unitname || '-'}]"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,9 +30,6 @@ class Formula < ActiveRecord::Base
|
||||
args << get_binding(quantities, args, length).eval(code)
|
||||
end
|
||||
args.last.map { |v| [v, nil] }
|
||||
rescue Exception => e
|
||||
puts e.message
|
||||
[[nil, nil]] * length
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
<% if @ingredients.any? %>
|
||||
<%= render partial: 'ingredients/options' %>
|
||||
|
||||
<%= error_messages_for *@quantities.map { |q| q.formula } %>
|
||||
|
||||
<table class="nutrients list odd-even">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
Reference in New Issue
Block a user