我正在遍历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