I've got a record with a period
field of type tsrange
.
I'm making a form to create it, and I'd like to keep using rails form helpers - I was wondering if there was some kind of convention for setting the date for the range's begin
and end
?
In my view this:
<%= form_with(model: @record) do |record_form| %>
<%= record_form.datetime_local_field :period %>
<% end %>
Results in an error undefined method 'strftime' for Mon, 01 Jan 1996 09:00:00 +0000..Mon, 01 Jan 1996 17:00:00 +0000:Range
Which makes sense, since I can't directly create one input for the range, but there doesn't seem to be any way to unpack the range attribute into its begin
and end
methods with something like
<%= record_form.datetime_local_field :period_begin %>
Since that errors with
undefined method 'period_begin' for #<ShiftPeriod id: nil, shift_pattern_id: nil, period: Mon, 01 Jan 1996 09:00:00 +0000..Mon, 01 Jan 1996 17:00:00 +0000, created_at: nil, updated_at: nil>
Other than building the inputs manually, is there any way to build the inputs for this range field type? Thanks!