Reputation: 1367
This a example of grails that I'm learning, I have two Domains, and whenever I call the controller, it gives me an error that I gave him a int but needed a package.domain. User and other is Test. which contain:
Test Domain:
Long id
Date created
bool enabled
User user
User Domain:
Long id
String firstname
String lastname
And my controller:
user.id = 1
def test = new Test(
created: new Date(),
enabled: true,
user: id));
... test.save(flush:true)
I don't know how to get the User domain using their attributes in my Test Domain. Can someone explain.
Upvotes: 0
Views: 81
Reputation: 11307
The Test
constructor expects a domain object for the value for user
property. So maybe try something like this (replacing 1
as appropriate):
def test = new Test(created: new Date(), enabled: true, user: User.get(1));
Upvotes: 1