I'm using grails 3.1.10, spring security service and mysql. I have tables: Shop and Product. So shop has many products in my tables. product_id is fk in Shop table. listed all shop at show/index page. when clicked shop name it direct you shop/show/id which shows shop's properties. (I made this sending shop id to url) What I'm trying to do is show all product which belong to this shop. I write this method in my shopController
def list = {
params.max = Math.min(params.max? params.int('max') : 20, 100)
Product product = Product.get(params.id)
List districts = Shop.findAllByProduct(product)
[productList : districts,
producttInstanceTotal: Product.count()]}
and in my shop/show.gsp is
<g:each in="${productList}" status="i" var="p" >
<div class="col-lg-2 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="#">
<img class="img-rounded" src="http://placehold.it/400x300" alt="">
</a>
<div class='text-center'>
<p><g:link controller="product" action="show" params="[id:p.id]">
${fieldValue(bean: p, field: "productName")}
</g:link></p>
<p>${fieldValue(bean: p, field: "productName")}</p>
<p>${fieldValue(bean: p, field: "productBarcode")}</p>
</div>
</div>
</g:each>
but nothing show. By the way I create all controllers and views using generate-all. thanks for any help