// UserDestroy deletes a User from the DB. This function is mapped
// to the path DELETE /users/{user_id}
UserDestroy deletes a User from the DB. This function is mapped
to the path DELETE /users/{user_id}
// UserDestroy deletes a User from the DB . This function is mapped // to the path DELETE / users / { user_id }
func UserDestroy(c buffalo.Context) error {
	c.Session().Clear()
	tx := c.Value("tx").(*pop.Connection)
	user := &models.User{}
	if err := tx.Find(user, c.Param("user_id")); err != nil {
		return c.Error(404, err)
	}
	if err := tx.Destroy(user); err != nil {
		return errors.WithStack(err)
	}
	c.Flash().Add("success", "Account was destroyed successfully")
	return c.Redirect(302, "/")
}
func UserDestroy ( c buffalo . Context ) error { c . Session ( ) . Clear ( ) tx := c . Value ( " " ) . ( * pop . Connection ) user := & models . User { } if err := tx . Find ( user , c . Param ( " " ) ) ; err != nil { return c . Error ( 404 , err ) } if err := tx . Destroy ( user ) ; err != nil { return errors . WithStack ( err ) } c . Flash ( ) . Add ( " " , " " ) return c . Redirect ( 302 , " " ) }
UserDestroy deletes a User from the DB.
UserDestroy deletes a User from the DB .
// clear user session first // Get the DB connection from the context // Allocate an empty User // To find the User the parameter user_id is used. // If there are no errors set a flash message // Redirect to the home page