Rails form.select attributes to show different values -
I have a model where I store the parameters in the database as an integer, no segment = 0, Section 1 = 1 and Section 2 = 2.
I want the user to be able to select the section under his name, not the stored value, that is, I want to select the form, 'no section, section 1, section 2' Show as an option, but then store the same value in database 0,1 or 2.
.form-group = f.label: section, 'Select a section' = f.select: section, (Show 'No section, Section 1, Section 2' on store 0, 1,2)
You must pass an array with options
= f.select: section, [["no section", 0], ["section 1", 1], ["section 2"]]
< P> The appropriate element will be selected according to the value, so if your object is a value for section = 2, then "section 2" will be selected when you will load the page. You can do more to see more
Comments
Post a Comment