Finally, here is the solution I came to:
@operations = Client.joins(:operations).select('clients.id,firstname, lastname,
sum(total) as total').group('clients.id,
firstname,lastname,total').paginate(page: params[:page])
It is not a will_paginate or smth eles problem, just PostgreSQL is more stri
Some correction has been applied:
@operations = Client.joins(:operations).select('firstname, lastname,
sum(total) as total').group('clients.id,
firstname,lastname').paginate(page: params[:page])
The same but in SQL:
select clients.firstname, clients.lastname, sum(operations.total) as total
fr
Even if the below solutions I found work in the console, it is no the case
in the controller because the result is no more Array or AR relation but
ActiveSupport::OrderedHash and 'paginate' method does not accept that:
*1st way:*
irb(main):019:0> cc =
Operation.includes(:client).group('operati
3 matches
Mail list logo