ryanb / nested_form

Rails plugin to conveniently handle multiple models in a single form.
MIT License
1.79k stars 505 forks source link

link_to_remove is not deleted vale only hide that so when we update that send hide value in parmeter #372

Open rohitmalik4 opened 8 years ago

rohitmalik4 commented 8 years ago

link_to_remove is not deleted vale only hide that so when we update that send hide value in parameter so my races is not updated,

So i want remove that value after click the Remove field.

Please help me

Mkunz89 commented 7 years ago

A quick and dirty solution for this, is to change your link_to_remove field to a basic link_to that points to your own method:

<%= f.fields_for :users ,do |user| %>
   <%= user.text_field :first_name, :placeholder => 'First Name' %>
   <%= user.text_field :last_name, :placeholder => 'Last Name' %>
   <%= link_to "Remove", archive_user_path(user.object), :method => :post if user.object.id%>
<%end%>
class UsersController < ApplicationController  
  def archive
    user = User.find(params[:id])
    user.archived = true
    user.save
    respond_to do |format|
        format.html { redirect_to :back}
    end
  end
end