Hi everyone I have a question , I looking for on google but I don't find an answer. I'm actually want to display Post model and User model by search in same page and for this I want to use Will_paginate to display all of them . I try this solution =>
**require 'will_paginate/array'
@posts =Post.search(params[:q]).order("created_at DESC")
@users=User.search(params[:q]).order("created_at DESC")
@all_records = (@posts + @users).paginate(:page =>params[:page], :per_page => 10)**
And In my view I want to display all query found ,so I try something like this =>
**<%unless @posts.nil?%>
<% @posts.each do |post| %>
....
**
**<% unless @users.nil?%>
<% @users.each do |user| %>
...**
<%= will_paginate @all_records %>
But it doesn't work nothing happend, so I want to know how to get @posts and @users records in @all_records to do something like this => **
<% @all_records[@posts].each do.. %>
<% @all_records[@usets].each do ..%>
** I saw some solutions that suggest to use two differentes paginate in my view like =>
**<%= will_paginate @posts %>
<%= will_paginate @users %>**
**But It's not want I want , I would'like only one paginate for all, Please Help me cause I'm going crazy, Thank you **
Aucun commentaire:
Enregistrer un commentaire