Paginate Multiple Models in Kaminari

后端 未结 3 996
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-01 18:14

I\'m creating a search page that will do an application wide search on users, posts, and comments. I currently have:

# POST /search
def index
  query = params[:q         


        
3条回答
  •  天涯浪人
    2021-02-01 19:00

    You could combine the results from the query and run page on that.

    users = User.search(query)
    posts = Post.search(query)
    comments = Comment.search(query)
    @results = users + posts + comments
    @results.page(params[:page])
    

提交回复
热议问题