Closed greenfork closed 5 years ago
I have solved this issue by using just order
option and applying almost complete rewrite of the scope like so:
order: proc do
scope.joins('LEFT JOIN smth').select('model.*, COUNT(*) as count_all').order('count_all')
end
Is there really no other way to accomplish this without writing a custom order
method?
@kaylaziegler so far I have not found it. Custom order proc doesn't seem so bad though.
I'm trying to sort by an aggregated value from the association.
Here is the snippet:
positions
is an association for the model.Everything works fine until I introduce pagination. I had to use this workaround:
My problem is that when I use
:order_by_value
, the assets are converted into an array and I have to use Kaminari'spaginate_array
method. But the resulting assets seem to be already paginated by the datagrid gem.The result is that I get sorting in the scope of a single page, meaning that the sorting is not applied to the whole dataset, only to the number of paginated results on the current page. How do I make the sorting to the whole dataset?