I’m developing a project, where there are two tables, region and district. In region I have:
+-------------+------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+------------+------+-----+---------+----------------+
| id | bigint(20) | NO | PRI | NULL | auto_increment |
| name | blob | YES | | NULL | |
+-------------+------------+------+-----+---------+----------------+
and in district I have:
+-------------+------------+------+-----+---------+----------------+
| 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 | |
+-------------+------------+------+-----+---------+----------------+
In the District view, The name of the district gets displayed, but not the Region name:
Id 1
Name Community College
Description Community College
Homepage
Logo
Region ctv.Region : 1
Streams
This is the show in the 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]
}
}
How can I modify my show closure in other to instead of displaying the Region.id I have the region.name instead?
Thanks
I assume you are just using the scaffolding? So try overriding toString() in Region, eg