How do I change the format ActiveRecord expects when parsing dates from a text field in a form?

前端 未结 5 1697
孤独总比滥情好
孤独总比滥情好 2021-01-04 02:37

The problem

  1. I have a Ruby on Rails model with a Date attribute.
  2. In the form for this model, I am using a single text field with a JQuery datepicker
5条回答
  •  南方客
    南方客 (楼主)
    2021-01-04 02:58

    You could try do something like this.

    $(function(){
     $('#date_picker').datepicker( {
          beforeShowDay: $.datepicker.noWeekends, 
          showOtherMonths: true,
          selectOtherMonths: true,
          dateFormat: 'dd-mm-yy',
          defaultDate: date,
          gotoCurrent: true
    
    }); 
    

提交回复
热议问题