I am omitting parents that have no children and doing this in the view:
<% @books.each do |b| %>
<% if b.comments.empty? %>
<% else %>
.....
My controller:
@pagy, @books = pagy_countless(Book.where(user_id: current_user.id).includes(:comments).order("comments.created_at DESC").group("comments.created_at, books.id"), items:10 )
And I am using pagy gem.
The issue is that the first page of the pagination is empty, with all the parents and their children showing on the second page. This is because I am omitting childless parents from the view and there are enough such parents that come on top that the first page is entirely empty.
How can I omit childless parents from the controller?