Grails - Very Simple Set Collection Value Not Working -


Controller of a bug:

This is the method for a bug, I created the BugInstance .activities and it had my activity object

  def = {def bugInstance = new bug () def activity = new activity (description: "created") bugInstance .properties = params bugInstance .addToActivities [Activity] [Bug Instance: Bug Instance]}  

Then I saw the method of saving, and the exact same impressions were printed, and the result is zero, so in some way it is by me Lost activity created And I do not know why this is actually the default behavior? Am I really doing something wrong, because there is no such reason why no such easy code will work.

  def save = {def bugInstance = new bug (params)) Println bugInstance.activities If (bugInstance.save (flush: true)) {flash.message = "$ {message (code: 'Default.created.message', Argus: [Messaging (code: 'bug.label', default): 'bug'), buginstance.id]}} "redirect (action:" show ", id: buginstance.id) } And {Render (See: "Create", Model: [Bug Instances: Bug Instance])}  

I know that I work around it by adding activity to the method of saving it I can do it, but I am doing the activity () -> save ()

P>

You never call () on the new example:

  def == {def bugInstance = new bug () DIF activity = new activity (description: "created") bugInstance. Properties = params bugInstance.addToActivities (Activity) BugInstance.save () return [bugInstance: bugInstance]}  

You do not have to save the activity since this activity has been in transit since the transit Will be saved as


Comments