stripe charge objectを反復しており、合計でamount
を合計します。ストライプで料金日付が同じ場合は、合計金額の合計
# Returns an array object of charges for a customer
@customer_charges = Stripe::Charge.all(:customer => current_user.stripeid)
再生回数:
<% @customer_charges.map do |c| %>
On Monday, you were charged a total of <%= c.amount %>
<% end %>
は確かに上記の日のために、各電荷の出力ライン以上のものではなく、合計しません。私が直面する難しさは、毎日のすべての費用を合計することです。誰かが私を正しい方向に向けることができますか?
"On Monday, you were charged a total of 200000"
"On Tueesday, you were charged a total of 500000"
etc...
の代わりに::
出力は次のようになります
On Monday, you were charged a total of 100000"
On Monday, you were charged a total of 100000"
etc...
私view
は日付を比較すると、それが正しく表示されませんif statements
の線で乱雑に見えます。
。 '創造されたもの'とは何ですか?それは列かメソッドか – tadman
'created'はストライプのjson unixタイムスタンプです:' "created":1462001409、 ' – Sylar
タイムスタンプの合計はなぜですか?それは私には意味がありません。日付として必要な場合は、 'Time.at(timestamp)'が変換されます。 – tadman