Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Product
- def self.get_random number_of_products = 1
- records = []
- runaway = 0
- while records.size < number_of_products
- record = find(:first, :offset => rand(count))
- if !records.include?(record) && record
- records << record
- end
- runaway += 1
- break if runaway > number_of_products * 10
- end
- records
- end
- end
Add Comment
Please, Sign In to add comment