title: Delete record from database on clicking button using ruby on rails
body: <p>I am working on a method that remove record from database when user press "Delete Button"
  The problem is that when I click on that button the Package I want to delete gets removed from the website but when I check database I found the record as it is.</p>
  
  <p>Controller:</p>
  
  <pre><code>def deletepackage(user_id,package_id)
    @package=Packages.find(:all, :condition=&gt;{:id =&gt; package_id}, 
                                             :condition =&gt; {:sender_Id =&gt; user_id})
      if (@package!=nil &amp;&amp; req.receivedByCarrier==false)
          @package.destroy
      elsif (@package!=nil &amp;&amp; req.receivedByCarrier==true)
          @package.destroy
      end
      return;
    end
  
    def delete
      deletepackage(1,1)
      package.destroy
      redirect_to(:action =&gt; 'show') 
    end
  
    def show
      @create_package=Packages.find(params[:id ])
    end
  </code></pre>
  
  <p>Show.html.erb :</p>
  
  <pre><code> &lt;%=form_for(:package,:url{:action=&gt;'create_packages/delete',
                               :id=&gt;@create_package.id})do |f| %&gt;
     &lt;p&gt;Are you sure you want to delete this package?&lt;/p&gt;
     &lt;%= f.submit "Delete" %&gt;
  </code></pre>