How To

Get a Random Model Record with ActiveRecord in Rails

In Rails 4+ with either Postgresql or SQLite by using RANDOM():

Model.order('RANDOM()').first

with MySQL:

Model.order('RAND()').first