I have two forms on one view page. One of these is an update form. The other form is a single button that goes to the same controller action but does not actually update the form. Here is the first form:
<%= form_for [@project, @schedule] do |f| %>
<%= f.fields_for :tasks do |builder| %>
<%= render 'task_fields', :f => builder %>
<% end %>
<p><%= link_to_add_fields "Add task", f, :tasks %>
<p><%= f.submit "Submit" %></p>
<% end %>
And here is the second form:
<%= form_tag project_schedule_path(@project, @schedule), method: "patch" do %>
<div><%= hidden_field_tag :emp_accepts, true %></div>
<%= submit_tag "Accept schedule", class: "btn btn-large btn-primary" %>
<% end %>
The problem is the strong parameters. The strong parameters require :schedule, which only the first form provides. So when I try to use the second form, an error is returned. Here are the strong params:
def schedule_params
params.require(:schedule).permit(:emp_accepts,
tasks_attributes: [:title, :content, :_destroy])
end