I'm using Grails 3.2.3 and created own views in grails-app/views/training:
in _short-training.gson
import com.example.trainings.Training
model {
Training training
}
json g.render(training, [includes:['id', 'name']])
in short-index.gson
import com.example.trainings.Training
model {
Iterable<Training> trainingList
}
json tmpl.'short-training'(trainingList ?: [])
in controller I tried two different approaches but noone of them is working. Both return 200 status but instead of 6 training instances I received:
render(view: "short-index", model: [trainingList: section.trainings])
[null,null,null,null,null,null]
respond section.trainings, [status: OK, view:"short-index"]
[]
it seems that trainings are visible in short-index.gson while used render but are not passed further. respond do not pass trainings at all. what am I missing?
Replace
With
The first argument can be used to specify the model variable name