date_field_tag,我如何设置默认日期? [Ruby on rails]

时间:2014-06-23 06:12:34

标签: ruby-on-rails ruby date default datefield

我想设置一个默认日期,实际日期,例如我如何设置它?

<%= 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之间的区别是什么?

2 个答案:

答案 0 :(得分:8)

试试这个:

  <%= date_field_tag(:datetime_ida, Date.today)%>

将默认日期作为第二个参数传递。

   you correctly set the default value of combo box as shown in your question.

答案 1 :(得分:0)

您应该将date_select用于:default