Nested Form
Nested form is a rails gem to manage multiple nested models in a single form. Dynamically we can add and remove fields using jQuery.
Add gem to Gemfile and run bundle to install it
gem "nested_form"
Add jquery_form in application.js
//= require jquery_nested_form
Then use the nested_form_for helper method to enable the nesting.
<%= nested_form_for @projects do |f| %>
use link_to_add and link_to_remove to dynamically add or remove records
<%= f.fields_for :tasks do |task_form| %>
<%= task_form.text_field :name %>
<%= task_form.link_to_remove "Remove this task" %>
<% end %>
<p><%= f.link_to_add "Add a task", :tasks %></p>