Created
February 26, 2020 13:17
-
-
Save bastianccm/1ceb95fe0ed6bd28461e7c7a9e8ddbd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
func (c *controller) detail(ctx context.Context, request *web.Request) web.Result { | |
questionID, err := strconv.Atoi(request.Params["question_id"]) | |
if err != nil { | |
return c.responder.ServerError(err) | |
} | |
var viewData struct { | |
Question Question | |
ErrorMessage string | |
} | |
if c.db.Preload("Choices").First(&viewData.Question, questionID).RecordNotFound() { | |
return c.responder.NotFound(gorm.ErrRecordNotFound) | |
} | |
return c.responder.Render("detail", viewData) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment