So I have a search controller that returns a array of Object IDs (in this case 'Users').
Since the search results array can contain hundreds of IDs, I'd rather fetch the actual Objects themselves only when I need to send them to the view. In short, I want to use pagination to fetch the Objects themselves beforehand for each chunk of IDs (i.e. 1..10, 11..20, etc), rather than have the view logic fetch the Objects. I have no idea how to accomplish this.
My controller code
users = [1,3,456,23423,234,23...]
#somehow have the pagination get the Objects from DB for each page
@persons = Kaminari.paginate_array(users).page(params[:page]).per(10)
View
- @persons.each do |person| #I WANT TO HAVE THE FULL WRITER OBJECT BY NOW
= person.name # instead of doing a 'User.find(person.id)' in the view
Any ideas?
Thanks in advance!