title: Rails - toggle boolean on click of a link
body: <p>I'm trying to make an app with rails 4 and simple form.</p>
  
  <p>I have models separately called Project, Scope and Finalise. Finalise belongs to Scope. Scope belongs to Project. Project accepts nested attributes for Scope and Finalise. Scope accepts nested attributes for Finalise.</p>
  
  <p>I have an attribute in my Finalise table called :draft.</p>
  
  <p>If a user creates a project and sets :draft as true, then I display a link, which when clicked, will change :draft to false.</p>
  
  <p>I have the following link in my view:</p>
  
  <pre><code>  &lt;%= link_to 'Finalise draft', finalise_toggle_draft_path(@project.scope.finalise.id), method: :patch %&gt;
  </code></pre>
  
  <p>I have the following method in my controller:</p>
  
  <pre><code>  def toggle_draft
      @finalise = Finalise.find(params[:finalise_id])
      @finalise.draft = false
      @finalise.finalised = Time.now
      @finalise.save
      redirect_to project_path(Project.find(params[:project_id]))
    end
  </code></pre>
  
  <p>When I try this, I get an error that says:  Couldn't find Project without an ID</p>
  
  <p>Does anyone know what I've done wrong?</p>
  
  <p>My routes for finalise are:</p>
  
  <pre><code>finalise_toggle_draft PATCH    /finalises/:finalise_id/toggle-draft(.:format)                                                  finalises#toggle_draft
                              finalises GET      /finalises(.:format)                                                                            finalises#index
                                        POST     /finalises(.:format)                                                                            finalises#create
                           new_finalise GET      /finalises/new(.:format)                                                                        finalises#new
                          edit_finalise GET      /finalises/:id/edit(.:format)                                                                   finalises#edit
                               finalise GET      /finalises/:id(.:format)                                                                        finalises#show
                                        PATCH    /finalises/:id(.:format)                                                                        finalises#update
                                        PUT      /finalises/:id(.:format)                                                                        finalises#update
                                        DELETE   /finalises/:id(.:format)                                                                        finalises#destroy
  </code></pre>