Created
May 2, 2011 06:28
-
-
Save taylor/951236 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Some methods for randomizing the processing order for results returned from a DB query | |
| Straight SQL | |
| SELECT * FROM `fax_stats` WHERE (`company` IN ('company123')) ORDER BY random(); | |
| ActiveRecord option #1 | |
| FaxStat.find(:all, :conditions => "company='company123'", :order => rand())[2]; | |
| ActiveRecord option #2 | |
| FaxStat.find(:all,:conditions => {:company => ['company123']}).to_ary.shuffle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment