This a continuation of this question.
I have an Address
class which contains basic street address information. I also have a User
class which 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"]
//some other stuff after this
And the Address
class looks something like this:
class Address {
static belongsTo = [user:User]
String streetAddress
String city
String state
String zip
BigDecimal taxRate
//some other stuff after this
I followed the tutorial here for the most part. 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
, the template returns ALL addresses associated with that 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 my problem has something to do with how the cargoDestinations
variable is mapped. How can I go about fixing this without changing my class files too much?