我正在遍歷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
線比較日期,並且看起來不正確的。
你或許應該使用'這裏,而不是'map' each'。什麼是「創造」?那是一列還是一種方法 – tadman
好的。 'created'是條紋的json unix timestamp:''created「:1462001409,' – Sylar
你爲什麼總計時間戳?這對我來說毫無意義。如果你需要它們作爲日期,'Time.at(timestamp)'將會轉換。 – tadman