I wish to display a list a selectable list of 1-42 on a form. I have an array assignment in the controller's new me to create the list:
@cabinet_position_list = (1..42).to_a
The number will be assigbed to device.position but I can't figure out how to display the numbers in the box. Here's the best I've come up with on the form:
<%= f.select :position, options_from_collection_for_select(@cabinet_position_list, "position", "?????") %>
You don't need options_from_collection_for_select in this case. Just:
f.select :position, @cabinet_position_list
or
f.select :position, (1..42).to_a
options_for_select(@cabinet_position_list)
应该可以工作!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.