我正在开发一个项目,其中有两个表,region
并且district
. 在region
我有:
+-------------+------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+------------+------+-----+---------+----------------+
| id | bigint(20) | NO | PRI | NULL | auto_increment |
| name | blob | YES | | NULL | |
+-------------+------------+------+-----+---------+----------------+
在district
我有:
+-------------+------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+------------+------+-----+---------+----------------+
| id | bigint(20) | NO | PRI | NULL | auto_increment |
| name | blob | YES | | NULL | |
| region_id | bigint(20) | NO | MUL | NULL | |
+-------------+------------+------+-----+---------+----------------+
在 District 视图中,将显示该地区的名称,但不显示 Region 名称:
Id 1
Name Community College
Description Community College
Homepage
Logo
Region ctv.Region : 1
Streams
这是show
在DistrictController
:
def show = {
def districtInstance = District.get(params.id)
if(!districtInstance){
flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'district.label', default: 'District'), params.id])}"
redirect(action : "list")
}
else{
[districtInstance : districtInstance]
}
}
如何修改我的show
闭包而不是显示Region.id
我有的region.name
?谢谢