// Destroy deletes a Contact from the DB. This function is mapped
// to the path DELETE /contacts/{contact_id}
Destroy deletes a Contact from the DB. This function is mapped
to the path DELETE /contacts/{contact_id}
// Destroy deletes a Contact from the DB . This function is mapped // to the path DELETE / contacts / { contact_id }
func (v ContactsResource) Destroy(c buffalo.Context) error {
	tx := c.Value("tx").(*pop.Connection)
	contact := &models.Contact{}
	if err := tx.Find(contact, c.Param("contact_id")); err != nil {
		return c.Error(404, err)
	}
	if err := tx.Destroy(contact); err != nil {
		return errors.WithStack(err)
	}
	c.Flash().Add("success", "Contact was destroyed successfully")
	return c.Redirect(302, "/contacts")
}
func ( v ContactsResource ) Destroy ( c buffalo . Context ) error { tx := c . Value ( " " ) . ( * pop . Connection ) contact := & models . Contact { } if err := tx . Find ( contact , c . Param ( " " ) ) ; err != nil { return c . Error ( 404 , err ) } if err := tx . Destroy ( contact ) ; err != nil { return errors . WithStack ( err ) } c . Flash ( ) . Add ( " " , " " ) return c . Redirect ( 302 , " " ) }
Destroy deletes a Contact from the DB.
Destroy deletes a Contact from the DB .
// Get the DB connection from the context // Allocate an empty Contact // To find the Contact the parameter contact_id is used. // If there are no errors set a flash message // Redirect to the contacts index page