I\'m using this method:
def self.lines_price_report(n)
Income.group(\'date(filled_at)\').having(\"date(filled_at) > ?\", Date.today - n).sum(:lines_
I guess this is because you use date(filled_at)
in GROUP BY but just filled at
in ORDER. As I guess order is taken from default scope you need to overwrite it by reorder
. I would suggest:
Income.sum(:lines_price).
group('date(filled_at)').
having("date(filled_at) > ?", Date.today - n).
reorder("date(filled_at) ASC")