Nested forms allows to generate, destroy and edit multiple models belongs to the parent. For achieving nested models we are using nested_form gem. gem "nested_form" Add to asset pipeline in application.js file //= require jquery_nested_form Run bundle install Recipe model ins has_many association with recipe_items. Nested attributes able to use as a accepts_nested_attributes_for : recipe_items class Recipe < ApplicationRecord has_many :recipe_items accepts_nested_attributes_for : recipe_items end class Recipe Item < ApplicationRecord belongs_to :r ecipe end Change form_for to nested_form_for helper method as per the nested form documentation. <%= nested_form_for @recipe do |form| %> <div class="field"> <%= form.label :name %> <%= form.text_field :name, id: :recepy_name %> </div> <div class="field">...
ruby on rails cheat sheet, ruby libraries, ruby on rails concepts, rails tutorials for beginner, ruby on rails