title: How to Create a form partial in rails to delete and update records with ajax
body: <p>I am trying to use a form inside a partial file to update and delete records but I am not sure about the routes(paths) to be used on the form. I have provided the form partial without the paths and with some information about my app. I need to help to fill the form with the correct routes </p>
  
  <h3>Task controller</h3>
  
  <pre><code>class TasksController &lt; ApplicationController
    def new
      @project = Project.find(params[:project_id])
      @task = @project.tasks.new
    end
  
    def create
      @project = Project.find(params[:project_id])
      @task = @project.tasks.create(task_params)
      respond_to do |format|
        format.html {redirect_to project_path(@project)}
        format.js
      end
  
    end
    def destroy
      @project = Project.find(params[:project_id])
      @task = @project.tasks.find(params[:id])
      @task.destroy
      respond_to do |format|
        format.html{redirect_to project_path(@project)}
        format.js
     end
    end
  </code></pre>
  
  <h3>_task.html.erb</h3>
  
  <pre><code>&lt;%= form_for '', remote: true do |f| %&gt;
    &lt;%= f.check_box :complete %&gt;
    &lt;%= f.submit "Update" %&gt;
    &lt;%= f.label :complete, task.name %&gt;
    &lt;%= link_to "Remove", '', method: :delete, data: {confirm: "Are you sure?"}, remote: true %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <h3>Task form</h3>
  
  <pre><code>&lt;%= form_with(model: [ @project, @project.tasks.build ],id:"new-task-form") do |form| %&gt;
  &lt;%= form.text_field :name%&gt;
  &lt;%= form.submit %&gt; 
  &lt;%end%&gt;
  </code></pre>
  
  <h3>Routes</h3>
  
  <pre><code>resources :projects do
       resources :tasks
   end
  </code></pre>