Revision: 33510
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 9, 2010 07:46 by smoothdzion
Initial Code
<% # Seems to work for me. I just set the code to a variable. @array = Model.all(:conditions => "condition_1 = true", :order => "name ASC", :limit => 10) @random_object = @array[rand(@array.length)] %>
Initial URL
http://www.mycollegesandcareers.com
Initial Description
I created an array of objects, but I wanted to reuse the array and pull one random object out of it so this is the code that I found thanks to this: http://www.ruby-forum.com/topic/144788
Initial Title
Random Object From an Array
Initial Tags
Initial Language
Rails