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

前端 未结 5 1696
孤独总比滥情好
孤独总比滥情好 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-04 03:01

    The timeliness gem makes ruby date/time parsing much more customizeable and integrates well with Rails.

    Since you're working with Rails, be sure to check out the validates_timeliness project as well by the same guy. It includes all of timeliness plus sophisticated date/time validation methods for ActiveModel.

提交回复
热议问题