Search code examples
grailsgroovygrails-controller

find default action in request.withFormat closure of grails version 2.3.8


request.withFormat {
        form multipartForm {
            flash.message = message(code: 'default.created.message', args: [message(code: 'user.label', default: 'User'), userInstance.id])
            redirect userInstance
        }
        '*' { respond userInstance, [status: CREATED] }
    }

this is the generated code snippet from the controller of my User domain class. where can we identify redirect action after processing the save action.

Every time after completing save action it is redirecting to "show" action by default . How it redirects? can we customise this flow?

Please help me


Solution

  • The redirect there is done, well, in the redirect line. It redirects to the saved instance, which implies the show. As you are using a HTML form to submit the form multipartForm branch in this kind of switch is executed.

    To redirect somewhere else you can to classic redirects with action etc. See the docs, e.g. redirect(action: 'edit')