Hi,
Is there a way to do a sum using GitHub - RubyMoney/money-rails: Integration of RubyMoney - Money with Rails?
field :order_total, type: Money
This doesn’t work (using Mongoid):
start_date = DateTime.new(2025,6,1,0,0,0)
OrderList.where(:created_at.gte => start_date).sum(order_total)
Nor does this:
pipeline = [
{
'$match': {
created_at: { '$gte': start_date }
}
},
{
'$group': {
_id: nil,
total_amount: { '$sum': "order_total" }
}
}
]
result = OrderList.collection.aggregate(pipeline).first
Any ideas?