ruby on rails - how to set default value for select field inside a form -


in code have:

<%= form_for(:category,:url=>{:action=>'update',:id=>@category.id}) |f|%>   <div class="field">     <b style="color: #808080;"> cuisine name:&nbsp;</b>     <%= f.select :cuisine_id,options_from_collection_for_select(@cuisines,"id","cuisine_name"),prompt:'select cuisine'  %> 

i using form update "cuisine_name". problem want set default value field.now getting values available.

you're there. docs:

options_from_collection_for_select(collection, value_method, text_method, selected = nil) 

so need pass 1 more argument create option selected default

options_from_collection_for_select(@cuisines,"id","cuisine_name", <your thing here>) 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -