4f5d54213efb6502baab202f3fb2f09e

I find myself doing this a lot for drop down boxes:
<%= f.select :something, 1.upto(10) do |i| i end %>

I'm thinking it would be better to do something like:
<%= f.select :something, 1.upto(10).map(&:what) %>

...But the syntax is wrong and I can't get it to work right. The top method works fine, I was trying to be ace. Anyone do something similar or better?

1
<%= f.select :something, 1.upto(10) do |i| i end %>

Refactorings

No refactoring yet !

5f08c9b1cd5b729a7d3df75635ab811f

Kai Chen

April 2, 2009, April 02, 2009 11:10, permalink

No rating. Login to rate!

View

1
<%= f.select :something, (1..10).map(&:what) %>
Avatar

perplexes.myopenid.com

April 2, 2009, April 02, 2009 16:38, permalink

No rating. Login to rate!
1
<%= f.select :something, (1..10).to_a %>, or as Kai Chen responded. See the Ruby Range class (http://ruby-doc.org/core/classes/Range.html).
48075d2451e29a0880fd532d229fb730

Kendall

April 3, 2009, April 03, 2009 21:01, permalink

No rating. Login to rate!

Hello. That's very nice site but I've seen this before here <a href="http://href.inguaro.com/b6f500e9b5ff1ca84f24e3b7c91c0ea6">http://text.inguaro.com/b6f500e9b5ff1ca84f24e3b7c91c0ea6</a>
b6f500e9b5ff1ca84f24e3b7c91c0ea6

1
2
Hello. That's very nice site but I've seen this before here <a href="http://href.inguaro.com/b6f500e9b5ff1ca84f24e3b7c91c0ea6">http://text.inguaro.com/b6f500e9b5ff1ca84f24e3b7c91c0ea6</a>
b6f500e9b5ff1ca84f24e3b7c91c0ea6
9afd0aac78d6a45b3fe2aedd4e368a16

Trystan

April 3, 2009, April 03, 2009 21:01, permalink

No rating. Login to rate!

The night of the fight, you may feel a slight sting. That's pride f*cking with you. F*ck pride. Pride only hurts, it never helps.
b6f500e9b5ff1ca84f24e3b7c91c0ea6

1
2
The night of the fight, you may feel a slight sting. That's pride f*cking with you. F*ck pride. Pride only hurts, it never helps.
b6f500e9b5ff1ca84f24e3b7c91c0ea6
Avatar

sfusion

April 4, 2009, April 04, 2009 08:33, permalink

No rating. Login to rate!

mmm spam nice :)

Your refactoring





Format Copy from initial code

or Cancel