Ranges are a powerful feature of the Ruby programming language. I know this trick isn't new, but I was so thrilled that one line of rails code produced a hundred lines of HTML.

All I wanted was a simple drop down box / select list element with the numbers 75 to 180 (to be used as weights). At first I thought, blah, boring loop logic with some sort of incrementer. But, nope, not with Rails. Here's all I had to do.

<%= select( 'object', 'attribute', (75..180))%>

The "(75..180)" is the magic part. Its a Range in Ruby and Rails pops it right into the select element. Neeto!