// Destroy deletes a Activity from the DB. This function is mapped
// to the path DELETE /activities/{activity_id}
Destroy deletes a Activity from the DB. This function is mapped
to the path DELETE /activities/{activity_id}
// Destroy deletes a Activity from the DB . This function is mapped // to the path DELETE / activities / { activity_id }
func (v ActivitiesResource) Destroy(c buffalo.Context) error {
	tx, ok := c.Value("tx").(*pop.Connection)
	if !ok {
		return fmt.Errorf("no transaction found")
	}
	activity := &models.Activity{}
	if err := v.scope(c).Find(activity, c.Param("activity_id")); err != nil {
		return c.Error(http.StatusNotFound, err)
	}
	if err := tx.Destroy(activity); err != nil {
		return err
	}
	return responder.Wants("html", func(c buffalo.Context) error {
		c.Flash().Add("success", T.Translate(c, "activity.destroyed.success"))
		return c.Redirect(http.StatusSeeOther, "/activities")
	}).Wants("json", func(c buffalo.Context) error {
		return c.Render(http.StatusOK, r.JSON(activity))
	}).Wants("xml", func(c buffalo.Context) error {
		return c.Render(http.StatusOK, r.XML(activity))
	}).Respond(c)
}
func ( v ActivitiesResource ) Destroy ( c buffalo . Context ) error { tx , ok := c . Value ( " " ) . ( * pop . Connection ) if ! ok { return fmt . Errorf ( " " ) } activity := & models . Activity { } if err := v . scope ( c ) . Find ( activity , c . Param ( " " ) ) ; err != nil { return c . Error ( http . StatusNotFound , err ) } if err := tx . Destroy ( activity ) ; err != nil { return err } return responder . Wants ( " " , func ( c buffalo . Context ) error { c . Flash ( ) . Add ( " " , T . Translate ( c , " " ) ) return c . Redirect ( http . StatusSeeOther , " " ) } ) . Wants ( " " , func ( c buffalo . Context ) error { return c . Render ( http . StatusOK , r . JSON ( activity ) ) } ) . Wants ( " " , func ( c buffalo . Context ) error { return c . Render ( http . StatusOK , r . XML ( activity ) ) } ) . Respond ( c ) }
Destroy deletes a Activity from the DB.
Destroy deletes a Activity from the DB .
// Get the DB connection from the context // Allocate an empty Activity // To find the Activity the parameter activity_id is used. // If there are no errors set a flash message // Redirect to the index page