How to format the input for time (with nanoseconds) in ruby on rails?

64 Views Asked by At

I would like to format the input (e.g. when you create a new 'entry' or edit it) with nanoseconds and without hours. I can display the time in (Minutes:Seconds,2Nanoseconds) with a helper, but I can't enter the time (especially the nanoseconds), when I create a new entry or trying to edit them. Does anyone know how to format an input (with or without simpleform)?

_form.html.erb

<%= simple_form_for @entry do |f| %> 
   <%= f.input :time, include_seconds: true %>
<% end %>
_application_helper.rb

def format_time(time)
   l(time, format: '%M:%S,%2N') unless time.blank?
end
0

There are 0 best solutions below