我有Rails 4.0.0时间格式字段用于开始时间和结束时间。 我想使用jQuery Mobile DateBox格式化时间,如'02:41 AM'。 如何将此字符串转换为Rails中的时间字段。 我的数据库是Postgresql。
migratiuon:
t.time :start_time, :null => false t.time :finish_time, :null => falseI have Rails 4.0.0 time format fields for start time and finish time. I want to use the jQuery Mobile DateBox which formats the time like '02:41 AM'. How can I convert this string to a time field in Rails. My database is Postgresql.
migratiuon:
t.time :start_time, :null => false t.time :finish_time, :null => false最满意答案
我决定忘记jQuery时间选择器,因为普通的Rails time_selector看起来很不错。 我遇到的一个问题是它输出两个选择选项字段,它们之间带有冒号(:)。 此冒号阻止data-type =“horizontal”显示内联。 解决方案如下。 此外,省略时间字段上的ignore_date会导致多参数超出范围错误。
<div> <fieldset data-role="controlgroup" data-type="horizontal"> <legend>Start Time</legend> <%= f.time_select :start_time, time_separator: "", ignore_date: true, ampm: true %> </fieldset> </div>I decided to forget about the jQuery time picker as the plain Rails time_selector looks pretty good. One issue I had with it was that it outputs two select options fields with a colon (:) in between them. This colon prevented data-type="horizontal" from displaying inline. The solution is as below. Furthermore, omitting ignore_date on a time field results in a Multiparameter out of range error.
<div> <fieldset data-role="controlgroup" data-type="horizontal"> <legend>Start Time</legend> <%= f.time_select :start_time, time_separator: "", ignore_date: true, ampm: true %> </fieldset> </div>更多推荐
发布评论