Rails Select in Form returns Index. I want to send the Text -



Rails Select in Form returns Index. I want to send the Text -

<%= f.select :owner, options_for_select(names) %>

here names array of names e.g. "harry", "barry", "joe". form element sets value of :owner index of selected alternative i.e. 0,1,2. want send value instead i.e. "harry", "barry", "joe".

is there alternative select so? if not, how can accomplish this?

map name in two element array of [text,value] pairs thus:

<%= f.select :owner, options_for_select(names.map {|name| [name,name]}) %>

ruby-on-rails forms select text indexing

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -