Separate date and time form fields in Rails

后端 未结 5 686
轮回少年
轮回少年 2020-12-23 16:43

I have an ActiveRecord model Eventwith a datetime column starts_at. I would like to present a form, where date and time for starts_at

5条回答
  •  遥遥无期
    2020-12-23 17:21

    Was looking at this today for a Rails project, and came across this gem:

    https://github.com/shekibobo/time_splitter

    Setting DateTimes can be a difficult or ugly thing, especially through a web form. Finding a good DatePicker or TimePicker is easy, but getting them to work on both can be difficult. TimeSplitter automatically generates accessors for date, time, hour, and min on your datetime or time attributes, making it trivial to use different form inputs to set different parts of a datetime field.

    Looks like it would do the job for you

提交回复
热议问题