4

I have some code like this in a controller:

def index

 @plays = current_user.plays.includes(:game).order("created_at desc")

 @wants = current_user.wants.includes(:game).order("created_at desc")

 @ratings = current_user.ratings.includes(:game).order("created_at desc") 

 @activities = (@plays + @wants + @ratings).sort_by {|a| a.created_at}.reverse

end

What I would like to do is paginate this using kaminari. To be clear I want all of these "activities" to be seen as one "feed" and paginate in the reverse created_at order. I don't want to paginate 5 of each type at a time or anything like that.

Any help you be great!

Clayton Correia
  • 263
  • 1
  • 3
  • 16

1 Answers1

6

Kaminari handles arrays...

Kaminari.paginate_array(@activities).page(params[:page]).per(10)
Carson Cole
  • 4,183
  • 6
  • 25
  • 35