// Show gets the data for one Widget. This function is mapped to
// the path GET /widgets/{widget_id}
Show gets the data for one Widget. This function is mapped to
the path GET /widgets/{widget_id}
// Show gets the data for one Widget . This function is mapped to // the path GET / widgets / { widget_id }
func (v WidgetsResource) Show(c buffalo.Context) error {
	tx, ok := c.Value("tx").(*pop.Connection)
	if !ok {
		return errors.WithStack(errors.New("no transaction found"))
	}
	widget := &models.Widget{}
	if err := tx.Find(widget, c.Param("widget_id")); err != nil {
		return c.Error(404, err)
	}
	c.Set("widget", widget)
	return c.Render(200, render.R.HTML("widgets/show.html"))
}
func ( v WidgetsResource ) Show ( c buffalo . Context ) error { tx , ok := c . Value ( " " ) . ( * pop . Connection ) if ! ok { return errors . WithStack ( errors . New ( " " ) ) } widget := & models . Widget { } if err := tx . Find ( widget , c . Param ( " " ) ) ; err != nil { return c . Error ( 404 , err ) } c . Set ( " " , widget ) return c . Render ( 200 , render . R . HTML ( " " ) ) }
Show gets the data for one Widget.
Show gets the data for one Widget .
// Get the DB connection from the context // Allocate an empty Widget // To find the Widget the parameter widget_id is used. // Make widget available inside the html template