我想设置一个默认日期,例如实际日期,我如何设置它?
<%= date_field_tag(:datetime_ida, value = nil, options = {})%>
还有,我如何在组合框中设置默认值
<%= select_tag :children_quantity, options_for_select([['0 Children', 0], ['1 Children', 1], ['2 Children', 2], ['3 Children', 3], ['4 Children', 4], ['5 Children', 5]], 1) %>
顺便说一下,date_field_tag和date_field之间的区别是什么? 试一试:
<%= date_field_tag(:datetime_ida, Date.today)%>
传递默认日期作为第二个参数。
you correctly set the default value of combo box as shown in your question.
你应该使用date_select:default