drop down menu - Rails 3 dropdown select boxes? -


i working on simple intranet application made rails 3.1.

i have model links has following fields:

name:string url:string colour:string 

i have put colour attribute class in view, so:

<a href="linkaddress" class="<%= link.colour %>">link name</a> 

at moment in new link form have simple form input in user can type , become href class expected.

what create dropdown list of preset options, these options red, green , blue (as example). seems simple, don't think there need helper.

i have read few other questions , answers on , seem show examples have name followed id number. want have code below:

<select name="colour">  <option value="red">red</option>  <option value="green">green</option>  <option value="blue">blue</option> </select> 

i'm sure simple can't head around it. i've read rails api info , select_for_tag has confused me!

just use standard select element in form set colour variable:

<%= f.select :colour, options_for_select([["red", "red"], ["green", "green"]], @link.colour) %> 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -