Rails create and destroy nested attributes on update model form -


i have products model has_many :tags.

the tags created on product creation.

when update product, can update attributes, including tags' attributes.

but question is, how can i, remove tag or create 1 when update product on product update form?

do have create separate tag form or that?

here update product form:

<%= form_for(@product), id: 'edit_form' |f| %>     <div class="field">         <%= f.label :name %><br>         <%= f.text_field :name %>       </div>       <div class="field">         <%= f.label :description %><br>         <%= f.text_area :description %>       </div>       <div class="field">         <%= f.label :location %><br>         <%= f.text_field :location %>       </div>       <div class="field">         <%= f.label :price %><br>         <%= f.text_field :price %>       </div>         <%= f.fields_for :tags |t| %>         <div class="field">           <%= t.label "hashtag" %>           <%= t.text_field :name %>         </div>         <% end %>       <div class="actions">         <%= f.submit "update item" %>       </div>     <% end %> 

i think easy using gem 'nested_form'. can repository here


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -