Rails: paginating by method, not by column
Is there a way in Rails (using will_paginate or any other kind of pagin开发者_StackOverflow中文版ation) to paginate by a method?
For example, I have a Movie table, associated with user ratings. I want to be able to paginate the movies based on the mean or standard deviation of the ratings (which are defined in methods in the Movie class, not as part of the database).
How do I do this?
May be what you can do is prepare the array based on mean or standard deviation of the ratings and then use pagination on the array, like:-
@result.paginate(:page => params[:page], :per_page => 10)
Thanks, Anubhaw
精彩评论