@make_num = (1..50).entries
something like?
<%= f.collection_select(:make_num, @make_num.collect {|c| [c, c]}) %>
i get wrong number of arguments (2 for 4)
thanks!
@make_num = (1..50).entries
something like?
<%= f.collection_select(:make_num, @make_num.collect {|c| [c, c]}) %>
i get wrong number of arguments (2 for 4)
thanks!
<%= f.select “make_num”, 1…50 %>
Ryan Bigg wrote:
<%= f.select "make_num", 1..50 %>
great thanks!! sometimes things are just too easy.
I think that'd be something like:
<%= f.select(:level, 1..200, {:prompt=> "N/A"}) %>
(Not sure if those curly braces are necessary, but they shouldn't hurt...)
Roy Pardee wrote:
I think that'd be something like:
<%= f.select(:level, 1..200, {:prompt=> "N/A"}) %>
(Not sure if those curly braces are necessary, but they shouldn't hurt...)
cool thanks!
Scott Kulik wrote:
Roy Pardee wrote:
I think that'd be something like:
<%= f.select(:level, 1..200, {:prompt=> "N/A"}) %>
(Not sure if those curly braces are necessary, but they shouldn't hurt...)
cool thanks!
oops one more thing. what if i want the option to be available when editing the item too?
Hmmm--that's different I think. With :prompt, the string you give isn't actually stored in the db--it'll get translated to a null. You can use the very same call in your edit view, and again nulls should be translated into the prompt value. But if you really want to store "N/A" in the db, you'll have to do something like:
# In your model, say: class MyModel < ActiveRecord::Base ALLOWABLE_LEVELS = (1..200).to_a << "N/A" end
# and then: <%= f.select(:level, MyModel::ALLOWABLE_LEVELS) %>
Mind you, your level field will have to accept strings if you do this...
HTH,
-Roy
[mailto:rubyonrails-talk@googlegroups.com] On Behalf Of Scott Kulik
Roy Pardee wrote:
Hmmm--that's different I think. With :prompt, the string you give isn't actually stored in the db--it'll get translated to a null. You can use the very same call in your edit view, and again nulls should be translated into the prompt value. But if you really want to store "N/A" in the db, you'll have to do something like:
# In your model, say: class MyModel < ActiveRecord::Base ALLOWABLE_LEVELS = (1..200).to_a << "N/A" end
# and then: <%= f.select(:level, MyModel::ALLOWABLE_LEVELS) %>
Mind you, your level field will have to accept strings if you do this...
HTH,
-Roy
thanks again roy that helps. the only thing is that edit shows the prompt N/A only if the value is already null.
if i set the level to 3 and then edit. there is no more N/A to chose from.
but yea i would want the value to be stored as NULL when selecting N/A.