Skip to content

Instantly share code, notes, and snippets.

@insane-dreamer
Created August 7, 2010 23:49
Show Gist options
  • Save insane-dreamer/513339 to your computer and use it in GitHub Desktop.
Save insane-dreamer/513339 to your computer and use it in GitHub Desktop.
find a random Item (that exists)
def self.random
photos = Photo.all.collect(&:id)
Photo.find(photos[rand(photos.length)])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment