Fixed associating benchmarks to test
This commit is contained in:
@ -72,9 +72,11 @@ func TestPostCreate(c flamego.Context, form forms.TestForm, errs binding.Errors)
|
||||
|
||||
_ = models.DB.Create(&test)
|
||||
|
||||
// bind benchmarks to test
|
||||
for _, v := range form.Benchmarks {
|
||||
fmt.Printf("%s", v)
|
||||
test.Association("Benchmarks").Append(models.Benchmark{ID: v})
|
||||
var benchmark models.Benchmark
|
||||
models.DB.First(&benchmark, v) // find benchmark
|
||||
models.DB.Model(&test).Association("Benchmarks").Append(&benchmark)
|
||||
}
|
||||
|
||||
c.Redirect(fmt.Sprintf("/test/%d", test.ID))
|
||||
|
Reference in New Issue
Block a user