Apr 27th, 2012, 12:23 PM
Adding create/update users magically?
I'm relatively new to Grails, and I'm hoping someone here can teach me a new piece of magic!
For all my domain objects, I'd like to add properties called "createUser" and "updateUser" and set the values to "springSecurityService.principal.username" on every create and edit operation.
Of course I could open every domain object, edit it, and then add the appropriate code, and do the same for all the controllers. But that feels very un-Groovy and very very un-Grailsy.
I think there's a "doWithDomainObjects" closure somewhere that I could use to add the properties. But how would I get inside the save/update methods of the controllers to set the appropriate data on the domain objects?