Skip to content

Instantly share code, notes, and snippets.

@iosadchiy
Created May 25, 2011 12:46
Show Gist options
  • Select an option

  • Save iosadchiy/990895 to your computer and use it in GitHub Desktop.

Select an option

Save iosadchiy/990895 to your computer and use it in GitHub Desktop.
rand_id = rand(Product.count)
rand_record = Product.first(:conditions => [ "id >= ?", rand_id])
@alg

alg commented May 25, 2011

Copy link
Copy Markdown

May work only for the records that are never deleted from the table. See some good strategies in the Advanced Rails Recipes book.

@iosadchiy

Copy link
Copy Markdown
Author

That's why it's here! I'd call this code 'malicious'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment