In my model Reports I have an attribute called :total. In Reports view I show the last 4 entries of this :total attribute (from previous Reports) on a chart. I found that when there wasn’t a previous entry, the chart wouldn’t render. When I went back and added “to_f” to the calculation, the chart would render and just show “0” where there was no entry. I’m glad it worked, but it was just a wild guess. Why did this work?
Share
Your values were probably nil. I’m guessing your formatter wasn’t keen on working with nils. However, nil implements a .to_f which returns 0.0, which your formatter could handle without crashing.
i.e.