Red Viper
Red Viper

Reputation: 507

Grails action redirect call

I'm new to grails and would just like to learn one at a time.

How can I call an action from another action in the same controller:

class ListProjectsController {
    def index () {      
        redriect(action: sampleMethod)
    }

    def sampleMethod () {
        //some codes here
    }
}

I tried redirect but this caused some error, help please?

here is a picture of the error message

http://i24.photobucket.com/albums/c22/Klifford_Kho/Capture_zps5j8nov9f.png

Upvotes: 1

Views: 106

Answers (3)

Uday
Uday

Reputation: 629

run grails clean command and update code to

redirect(action: 'sampleMethod')

Upvotes: 1

Burt Beckwith
Burt Beckwith

Reputation: 75681

That's the old style from before Grails 2 when actions were closures. You could quote the name or refer to the closure directly by name. When using methods you can't refer to them as objects, so you just have to quote the name:

redirect(action: 'sampleMethod')

Upvotes: 3

Lewis Norton
Lewis Norton

Reputation: 7151

You have misspelled the method name redirect as redriect.

Upvotes: 0

Related Questions