由于我认为 <%= "%.1f" % (r.lint/@compare*100) %> 行,我的 rails 应用程序中出现了“无法将数组强制转换为浮点数”错误。任何帮助,将不胜感激。
看法
<% @result.each do |r| %>
<%= "%.2f" % (r.lint/227) %></br>
<%= "%.2f" % (r.lint/227/2.47) %></td>
<%= "%.1f" % (r.lint/@compare*100) %>
<% end %>
控制器
def trial
@result = Result.where('trial_id' => params[:trial_id]).order('lint DESC')
@compare = Trial.where('trial_id' => params[:trial_id]).pluck(:comp_lint)
end