I am trying to randomly select a record from the database and display it in my view. The catch is I don't want the selected random record to repeat until all the records are selected at least once. For instance, let's say my table has 10 records, so I want to pick any one random record and make sure that, that randomly selected record is not selected again until the other nine records are selected at least once.
snippet:
offset = rand(Quote.count)
@qotd = Rails.cache.fetch( "term", :expires_in => 6.seconds){ Quote.offset(offset).first }