I have a form with a has_many association and I would like to submit multiple forms via ajax so the parent form's show page can be updated dynamically.
I have the following models (they are in mongoid but i don't think it matters between mongoid and activerecord):
class User
include Mongoid::Document
include Mongoid::Timestamps
has_many :tasks
end
class Task
include Mongoid::Document
include Mongoid::Timestamps
belongs_to :user, inverse_of: :tasks
end
I have a form which renders n partials of the form:
<%= form_for @task, remote: true do |f| %>
<%= f.text_field :name %>
<%= f.submit %>
<% end %>
for new tasks on the show.html.erb for user via ajax.
How can i write a single submit button on the show.html.erb to submit all of the tasks at once while associating them with the parent user?