0
私はPERIODとGENERAL LEDGERでグリッドを表示するRailsビューを持っていて、累計を表示したいと思います。しかし、以下のケースでは、 "TOTAL"列の@cumulative_totalが最も近いドルに切り上げられているので、general_ledger列に正しく表示されていてもセントは表示されません。私が間違っていることは何ですか?Rails 3 View - Rounding Up
私が表示している間、あなたが '整数' に課金額を変換しているので、それがあると思い<% @cumulative_total = 0 %>
<div id="gl_crosstab">
<table>
<tr>
<th>Period</th>
<% @general_ledgers.each do |g| %>
<th><%= g.general_ledger_number %></th>
<% end %>
<th>Total</th>
<th>% Expended</th>
</tr>
<% @expected_billings.group_by(&:period_id).each do |eb| %>
<tr>
<td><%= eb[1].first.period.pe_number %></td>
<% eb[1].each do|p| %>
<td><%= number_to_currency(p.expected_amount) %></td>
<% end %>
<td>
<% @cumulative_total = @cumulative_total + eb[1].inject(0){|sum,billing| sum+billing.expected_amount.to_i} %>
<%= number_to_currency(@cumulative_total) %> </td>
<td><%= number_to_currency((@cumulative_total/@sla.project_total)*100) %> % </td>
</tr>
<% end %>
<tr>
<td><b>Total Budget</td>
<% @total_expected_billings.each do |teb| %>
<td><b><%= number_to_currency(teb[1].inject(0){|sum,billing| sum+billing.expected_amount.to_i}) %></td>
<% end %>
<td><b><%= number_to_currency(@expected_billings.inject(0){|sum,billing| sum+billing.expected_amount.to_i}) %> </td>
<td><b><%= number_to_currency((@expected_billings.inject(0){|sum,billing| sum+billing.expected_amount.to_i}/@sla.project_total)*100) %> % </b></td>
</tr>
</table>
</div>
ありがとうございます!その小さな「f」はすべてのものです! :) –