Module: TimeOfDayAttr::FormBuilderExtension

Extended by:
ActiveSupport::Concern
Defined in:
lib/time_of_day_attr/form_builder_extension.rb

Instance Method Summary collapse

Instance Method Details

#time_of_day_field(method, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/time_of_day_attr/form_builder_extension.rb', line 5

def time_of_day_field(method, options = {})
  options[:value] ||= begin
    value = object.public_send(method)
    localize_options = options.extract!(:format, :omit_minutes_at_full_hour)
    TimeOfDayAttr.localize(value, localize_options)
  end
  text_field(method, options)
end