Paginate Multiple Models in Kaminari?

Before thinking about a solution, you need to first define exactly what you want the final result to be. If you want to display a few of each type of record on the results page you can modify the approach you posted and combine the three paginated results using.

Before thinking about a solution, you need to first define exactly what you want the final result to be. If you want to display a few of each type of record on the results page you can modify the approach you posted and combine the three paginated results using: @results = @users + @posts + @comments @results. Sort!

{ |a, b| a. Score(query) > b. Score(query) } Each object will need to have an instance method 'score' that will let it sort based on the query priority.

Also, you will need to modify your view to handle correct rendering of each item and ensure that the pagination is called on the model with the most pages. Alternatively, a more robust method would be to add a full-text search service (such as Index Tank, Web Solr, Thinking Sphinx). The technology for what's hot for these moves quickly, so do some research and find one that fits your needs.

Example syntax for this would be something like: User. Multi_solr_search query, models: Post, Comment.

Ever since this commit: https://github. Com/amatsuda/kaminari/commit/f9f529fb68ab89feea38773a4c625c1b14859128 You can do the following In your view you can do this: true, :param_name => "user_page" %> true, :param_name => "post_page" %> true, :param_name => "comment_#{some_post_id}_page" %> and then in your controller you can refer to them in this way: @users = User. Search(query).

Page(params:user_page) @posts = Post. Search(query). Page(params:post_page) @comments = Comment.

Search(query). Page(params:comment_page).

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).

1 Part of the benefit of gems like kaminari and paginate is that they use the SQL limit and offset clauses. If you solve the problem this way you loose that benefit! – Kevin Sylvestre Jun 10 at 17:27 Ah, whoops.My bad I was going to suggest full text search since searching with AR feels like a ugly hack.

– Devin M Jun 10 at 17:48.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions