- How will i add predefined values to a collection_select? Like... US UK 开发者_如何学PythonAUS PAK
The collection_select
helper is used for when you want the options within the select element to come from a collection of ActiveRecord models. For your requirements you should use the select
helper in combination with options_for_select
:
<%= select(:country, :country_id,
options_for_select([['US', 1], ['UK', 2], ['AUS', 3], ['PAK', 4]])) %>
- select API documentation
精彩评论