Post Archive
› November 30, 2005
Rapid to Reproduce Random Rotator for Ruby on Rails
Dan Benjamin, system developer of the powerhouse new A List Apart site among many other things, has shared a little morsel of Ruby-On-Rails goodness for those who've adopted the framework. It's his classic image rotator ala rails and its ridiculously short.
Comments
1. November 30, 2005 06:44 PM
2. November 30, 2005 06:57 PM
3. January 6, 2006 03:51 AM
Quote this comment
Dan Posted…
How would the code look if you were pulling image urls from a database?
riffraff Posted…
Actually, I think he can avoid some code like this:
def rand_img files=Dir['*.{jpg,gif,png}'] files[rand(f.length)] endToo bad there isn0t an Enumerable#rand :)