Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

date_field_tag, how i set up a default date? [Ruby on rails]

I wanted to set a default date, the actual date for example, how i set it up?

<%= date_field_tag(:datetime_ida, value = nil, options = {})%>

Also how can i set up a default value in a combo box

<%= 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) %>

and by the way, what's the difference between date_field_tag and the date_field?

like image 477
CesarWelch Avatar asked Jun 23 '14 06:06

CesarWelch


1 Answers

try this out:

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

pass the default date as second parameter.

   you correctly set the default value of combo box as shown in your question.
like image 173
Sachin Singh Avatar answered Oct 23 '22 08:10

Sachin Singh