title: Add logic to delete method in Sinatra
body: <p>I have been learning Sinatra for a couple of days now so I am still quite new. I am simply created a notes application and have added a delete function within the app. </p>
  
  <p>Here is my Controller:</p>
  
  <pre><code># Will display title of all notes
  get '/' do
    @notes = Note.all
    erb :index
  end
  
  # Will display content within selected note
  get '/:id' do
    @note = Note.where(id: params[:id]).first
    erb :note_description
  end
  
  # Will delete item from notes.
  delete '/:id' do
    Note.delete(params[:id])
  
    redirect '/'
  end
  </code></pre>
  
  <p>Here is my view with html/erb:</p>
  
  <pre><code>&lt;div class="container"&gt;
    &lt;p&gt;&lt;a href="/"&gt;Return to Notes&lt;/a&gt;&lt;/p&gt;
  
    &lt;h1&gt;&lt;%= @note.title %&gt;&lt;/h1&gt;
    &lt;p&gt;&lt;%= @note.content %&gt;&lt;/p&gt;
  
  
    &lt;form onsubmit="confirm('Are you sure you want to delete the following note?')" action="/&lt;%= @note.id %&gt;" method="POST"&gt;
      &lt;input type="hidden" name="_method" value="DELETE"&gt;
      &lt;button type="submit"&gt;Delete&lt;/button&gt;
    &lt;/form&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>As you can see, I have created a <code>delete</code> button and have a pop-up on submit when you click it. This will simply verify if the user really wants to delete the object. What happens though, is no matter what I click the item will be deleted and I will be redirected to the home page. I want to add logic where the app will only delete and redirect me to home page if the user clicks okay. If they click cancel nothing should happen. Any advice or help would be greatly appreciated.</p>