Randomize the talks

This commit is contained in:
Petko Bordjukov 2015-10-06 16:59:34 +03:00
parent 36c61cc531
commit e56bd9328d
No known key found for this signature in database
GPG Key ID: 2ABD54A3A1D5078A
2 changed files with 9 additions and 1 deletions

View File

@ -9,4 +9,12 @@ class ApplicationController < ActionController::Base
# request.env['HTTP_X_FORWARDED_FOR'] ||
request.remote_ip
end
def sort_seed
if session[:random_sort_seed].present?
session[:random_sort_seed].to_i
else
session[:random_sort_seed] = Random.new_seed
end
end
end

View File

@ -1,6 +1,6 @@
class TalkPreferencesController < ApplicationController
def index
@talks = Talk.all(params: {locale: I18n.locale})
@talks = Talk.all(params: {locale: I18n.locale}).to_a.shuffle(random: Random.new(sort_seed))
end
def show