Skip to content

Instantly share code, notes, and snippets.

@tadast
Created March 20, 2014 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tadast/9659856 to your computer and use it in GitHub Desktop.
Save tadast/9659856 to your computer and use it in GitHub Desktop.
ActiveRecord#sample for postgres
class ActiveRecord::Base
def self.sample
order('random()').first
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment