i have got a problem in my project. i have f.date_select field in my
form and i want to set the default date = current date+30. but
f.date_select is not allowing me to do so. there are options to set year
only not month and day.
see what i have followed:
You can do two things. If you must have a date in the form, then do the
same thing for the existing record as you do for the new one: set it in
the controller. Otherwise, if the date can actually be blank, add
:include_blank => true to the f.date_select statement.
Keep in mind that when using form_for, and therefore the f.* notation,
FormBuilder will associate the date selector with the valid_til method
on whatever object you pass into form_for. When initialized, whatever
value you have in object.valid_til will be used to set the date
selector’s date. If valid_til is nil, the current date will be used,
unless :include_blank is true, and then it will be blank.