I have a rails 3 app that displays user submissions in order of how many votes they have. I have a model method called "rank" that calculates the score for each submission. Currently, when listing all the submissions I am using the following in my submissions\_controller.rb

```
  def index
    @submissions = Submission.all.sort_by(&:rank).reverse
  end

```

However, I want to add pagination to this, and it seems that neither 'will\_paginate' or 'kamninari' will work properly here. This is because I need to sort the database columns by rank before paginating. Is there a better way to phrase my query so that pagination could be created with one of these gems, or do you know of a good custom pagination solution?

Thanks!