// List gets all Widgets. This function is mapped to the path
// GET /widgets
List gets all Widgets. This function is mapped to the path
GET /widgets
// List gets all Widgets . This function is mapped to the path // GET / widgets
func (v WidgetsResource) List(c buffalo.Context) error {
	tx, ok := c.Value("tx").(*pop.Connection)
	if !ok {
		return errors.WithStack(errors.New("no transaction found"))
	}
	widgets := &models.Widgets{}
	q := tx.PaginateFromParams(c.Params())
	if err := q.All(widgets); err != nil {
		return errors.WithStack(err)
	}
	c.Set("widgets", widgets)
	c.Set("pagination", q.Paginator)
	return c.Render(200, render.R.HTML("widgets/index.html"))
}
func ( v WidgetsResource ) List ( c buffalo . Context ) error { tx , ok := c . Value ( " " ) . ( * pop . Connection ) if ! ok { return errors . WithStack ( errors . New ( " " ) ) } widgets := & models . Widgets { } q := tx . PaginateFromParams ( c . Params ( ) ) if err := q . All ( widgets ) ; err != nil { return errors . WithStack ( err ) } c . Set ( " " , widgets ) c . Set ( " " , q . Paginator ) return c . Render ( 200 , render . R . HTML ( " " ) ) }
List gets all Widgets.
List gets all Widgets .
// Get the DB connection from the context // Paginate results. Params "page" and "per_page" control pagination. // Default values are "page=1" and "per_page=20". // Retrieve all Widgets from the DB // Make Widgets available inside the html template // Add the paginator to the context so it can be used in the template.