开发者

Drop down with predefined values


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜