In my domain class com.example.users.User I added transient field carnets:
class User implements Serializable {
...
def carnets
static transients = ['springSecurityService', 'carnets']
...
}
and in my gson view user/_user.gson I'd like to render it:
import com.example.users.User
model {
User user
}
json g.render(user, [excludes:['password', 'deleted', 'enabled', 'accountExpired', 'accountLocked', 'passwordExpired', 'authorities']]) {
//"carnets" g.render(template:"/carnet/index", collection: user.carnets, var:'carnets')
"carnets" tmpl.'/carnet/index'(user.carnets)
}
but I've received:
Caused by: grails.views.ViewRenderException: Error rendering view: Template not found for name /carnet/index
Carnet's views gson files were autogenerated and works fine when executed from CarnetController.
What am I missing?
In my use case (Grails 3.3.0), I had to change the template path from:
tmpl.'message/message'
to:
tmpl.'/message/message'
(added leading slash).
Using the ../
syntax worked in development, but caused an error for me when deploying the WAR file to Tomcat. See: [https://github.com/grails/grails-views/issues/140]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With