I have a domain class that looks like this:
class Offerbyuser {
Number offerPrice
Number minHours
static constraints = {}
}
Then in a controller, I do this:
def offer = new Offerbyuser(offerPrice:1, minHours:3)
offer is always NULL. Why? Am I missing something obvious?
UPDATE: so this DOES work, but what’s not working I found out is the method after that.
user.addToOutgoingOffers(offer)
user has a one-to-many relationship with Offerbyuser domain class:
class User {
static hasMany = [outgoingOffers:Offerbyuser]
}
I get this error:
groovy.lang.MissingMethodException: No signature of method: twitter4j.UserJSONImpl.addToOutgoingOffers() is applicable for argument types: (test.Offerbyuser) values: [Offer by user – Price: 1, Tweet hours: 3]
Your code works fine for me. I think that it maybe your controller class is not in the same package with your domain class, and you maynot include the domain class. Grails can not find the class you “new”, but since Groovy is a dynamic language it won’t throw an error.
Please try this:
In domain class
In controller: