Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save igorkasyanchuk/556fd78d479bedc5a142939abc37f9b9 to your computer and use it in GitHub Desktop.
Save igorkasyanchuk/556fd78d479bedc5a142939abc37f9b9 to your computer and use it in GitHub Desktop.
return users in random order (but use this order in next request)
randomizer = Random.new
session[:seed] ||= randomizer.rand(1.0)
User.connection.execute "select setseed(#{session[:seed].to_f})"
@users = User.order('random()').page(params[:page]).per(24)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment