Monday, February 28, 2011

Show seconds in datetime_select

By default the datetime_select only shows date, hour and minutes. But I do want to show the seconds for user to change. the default way of calling is like this:
<%= f.datetime_select :start_time %>
After I keep bundle open several gems, I found the option in active_pack, date_helper.rb:
@options[:discard_second] ||= true unless @options[:include_seconds] && !@options[:discard_minute]
OK, so :include_seconds can control this behavior, easy job then:
<%= f.datetime_select :start_time, :include_seconds => true %>

No comments:

Post a Comment