开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜