I am wondering if there is any cleaner way to write the controller code?
Normally when doing a save you create a new object from the params and validate/save the object.
def order = new Order(params)
if(order.validate() && order.save())
When doing an update action you get the object from the DB and the bind the params/validate/save.
def order = Order.get(params.id)
order.properties = params
if(order.validate() && order.save()) {
Is there a way in which the save and update can be combined in a saveOrUpdate action?
1 Answer