It will always be a little more difficult to paginate and join the has_many
or has_and_belongs_to_many
with will_paginate, or even any pagination solution.
If you do not need to request a federated link, you can delete it. You lose the advantage of getting related positions in one request, but you do not lose this.
If you need to request on it, and, presumably, you want sales to have only positions, you need to pass the count option: call paginate, which indicates the additional parameters that are used to call to calculate how many items are. In your case:
@sales.paginate(:per_page => 4, :page => params[page], :count => {:group => 'sales.id' })
source share