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