Rails if语句用于日期字段?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (1)
  • 关注 (0)
  • 查看 (68)
 <div class="form-group">
    <%= f.label :sinDate, "Down Since", class: "col-md-2 control-label" %>
    <div class="col-md-4">
        <%= f.date_field :sinDate, class: "form-control" %>
      <p><small>This is optional, use if the down date was before today.</small></p>
    </div>
  </div>
提问于
用户回答回答于
<%= f.date_field :sinDate, as: :date, 
    value: (f.object || Date.Today).try(:strftime,"%m/%d/%Y"), 
    class: 'form-control' %>

扫码关注云+社区

领取腾讯云代金券