Skip to content

Instantly share code, notes, and snippets.

@joshnesbitt
Created March 30, 2011 09:22
Show Gist options
  • Select an option

  • Save joshnesbitt/894115 to your computer and use it in GitHub Desktop.

Select an option

Save joshnesbitt/894115 to your computer and use it in GitHub Desktop.
def random
find(:first, :offset => (count * rand).to_i)
end
@DubitPlatform
Copy link
Copy Markdown

Or how about getting mysql to do the random? https://gist.github.com/894170

@newacct
Copy link
Copy Markdown

newacct commented Nov 12, 2011

(count * rand).to_i should be written as rand(count)

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