Search
 
SCRIPT & CODE EXAMPLE
 

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

PREVIOUS NEXT
Code Example
Ruby :: how to write an array in ruby 
Ruby :: ruby on rails recover data in params with form tag 
Ruby :: rails deliver_later with delay 
Ruby :: rails order nil last 
Ruby :: rails admin overwrite view 
Ruby :: ruby create object with attributes 
Ruby :: rails check log level of application 
Ruby :: update_all 
Ruby :: rails spreadsheet email attachment 
Ruby :: capybara click with offset 
Ruby :: ruby String split second parameter 
Ruby :: rails group every 10 items in array 
Ruby :: replace strring by another string ruby 
R :: export csv in r 
R :: remove null element from list r 
R :: r loops 
R :: r split string column by delimiter 
R :: r dataframe column factor 
R :: rename columns based on a variable in r 
R :: combine columns in r 
R :: ggplot_regression_line 
R :: ggplot2 legend text 
R :: what is factor in r programming 
R :: order rows of a dataframe using a vector 
R :: r mode 
R :: read.table tab separator 
R :: bioFabric r 
R :: R difference | and || 
R :: Extract the text of all list elements in r from html 
R :: dplyr left join only certain columns 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =