Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

ruby on rails multiple models pagination

@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}

Kaminari.paginate_array(@activities).page(params[:page]).per(10)
 
PREVIOUS NEXT
Tagged: #ruby #rails #multiple #models #pagination
ADD COMMENT
Topic
Name
6+3 =