This is a continuation of this issue.
I have an Address class that contains basic street address information. I also have a User class that has the attributes physicalAddress , mailingAddress , cargoDestinations and cargoSources . The User class looks something like this:
class User { String username String password String firstName String lastName String businessName String phoneNumber Address physicalAddress Address mailingAddress static hasMany = [accounts:Account, cargoSources:Address, cargoDestinations:Address, cargoes:Cargo, loadsLogged:Load, loadsDelivered:Load] Set accounts, cargoSources, cargoDestinations, cargoes static mappedBy = [loadsLogged:"loggedBy", loadsDelivered:"deliveredBy"]
And the Address class looks something like this:
class Address { static belongsTo = [user:User] String streetAddress String city String state String zip BigDecimal taxRate
I mostly followed the tutorial here . In step 5, my template looks like this:
<g:select from="${account.user.cargoDestinations}" name="cargoDestinations" value=""> </g:select>
The problem is that instead of returning only cargoDestinations template returns ALL addresses associated with this user. If I change from="${account.user.cargoDestinations}" to from="${account.user.physicalAddress}" or from="${account.user.mailingAddress}" , I get the expected result, so I know that my problem is with the way the cargoDestinations variable is cargoDestinations . How can I fix this without changing the class files too much?
source share