Grails - Saving rejected null even though parameter initialized -



Grails - Saving rejected null even though parameter initialized -

im new grails , ive run (probably dumb) problem. when seek save domain instance fails ... on field 'deviceusages[0].start': rejected value [null]...

this action on fails:

def save() { def user=params.remove('user.id') def deviceinstance=new device(params) deviceusage du = new deviceusage(device: deviceinstance, user: user.get(user), start: new date(), end: null) if(user){ deviceinstance.addtodeviceusages(du) } if (!deviceinstance.save(flush: true)) { deviceinstance.errors.each { println } render(view: "create", model: [deviceinstance: deviceinstance]) homecoming } du.save() flash.message = message(code: 'default.created.message', args: [message(code: 'device.label', default: 'device'), deviceinstance.id]) redirect(action: "show", id: deviceinstance.id) }

as can see, 'start' initialized new date... domain classes in question following:

class device { string name string description date created = new date() date deactivated user currentuser static hasmany = [ deviceusages: deviceusage ] static constraints = { name(nullable:false, blank:false) description(nullable:false, blank:true) created(nullable:false, display:false) deactivated(nullable:true) currentuser(nullable:true) }

and

class deviceusage implements serializable{ date start date end static belongsto = [ device: device, user: user ] static constraints = { start(nullable:false) end(nullable:true) } static mapping = { id composite: ['device', 'user'] version false }

thanks help

well managed solve it... apparently new deviceusage(device: deviceinstance, user: user.get(user), start: new date(), end: null) leaves start null whatever reason, adding du.start = new date() @ next line fixed it...

grails null save grails-domain-class grails-controller

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -