Я видел, что есть отношение has_many, поэтому меняем форму и контроллер foot ==> foots
Как показано ниже: -
<%= bootstrap_form_with(model: @morning, url: morning_path, local: true) do |form| %>
.....
....
<%= form.fields_for :foots do |foot| %>
<%= foot.select :hour, [["Escolha um Horário", 0], ["06:00 às 06:30", "um"], ["06:30
às 07:00", "dois"], ["07:00 às 07:30", "tres"]], { hide_label: true, required: true, wrapper: { class: 'has-
warning', data: { foo: 'bar' } } }, { class: "selectpicker" } %>
<% end %>
.....
....
<% end %>
Затем в контроллере
def create
@morning = Morning.new(morning_params)
if @morning.save
flash[:notice] = "Your custom message."
else
flash[:alert] = "Your custom message."
end
redirect_to morning_path
end
private
def morning_params
params.require(:morning).permit(:name, :hour, foots_attributes: [ :name, :hour ])
end
### Редактировать Добавить поле имени в дочернюю форму
<%= bootstrap_form_with(model: @morning, url: morning_path, local: true) do |form| %>
<!-- Morning name in morning table -->
<%= form.text_field :name, placeholder: "Morning name", hide_label: true, required: true%>
<%= form.select :hour, [["Escolha um Horário", 0], ["06:00 às 06:30", "um"], ["06:30 às
07:00", "dois"], ["07:00 às 07:30", "tres"]], { hide_label: true, required: true, wrapper: { class: 'has-
warning', data: { foo: 'bar' } } }, { class: "selectpicker" } %>
<%= form.fields_for :foots do |foot| %>
<!-- Foot name in foots table -->
<%= foot.text_field :name, placeholder: "Foot name", hide_label: true, required: true%>
<%= foot.select :hour, [["Escolha um Horário", 0], ["06:00 às 06:30", "um"], ["06:30
às 07:00", "dois"], ["07:00 às 07:30", "tres"]], { hide_label: true, required: true, wrapper: { class: 'has-
warning', data: { foo: 'bar' } } }, { class: "selectpicker" } %>
<% end %>
<%= form.submit "Registrar horário", class:"btn btn-primary", data: { disable_with:
'Registrando....' } %>
<% end %>