Rails 3 jquery date picker date not saving to database

后端 未结 6 1914
独厮守ぢ
独厮守ぢ 2020-12-31 02:21

When I submit my form I can see the date being sent to in the post. However, It doesn\'t save the date. If I do a date check it says it is not in the proper format. Here

6条回答
  •  时光说笑
    2020-12-31 02:44

    As noted by @BaronVonBraun above rails doesn't seem to handle that format. Changing it as he suggested worked. However, for those wanting a different format than yy-mm-dd you can use the following. The user sees the format you want while rails gets the format it needs.

    $j(function(){
        $j("#show_date").datepicker({altField: '#mile_date', altFormat: 'yy-mm-dd'});
    });
    

    The show_date is the id of the field they see and the mile_date is a hidden field with the date rails needs.

    Here is the documentation.

提交回复
热议问题