views:

31

answers:

2

Recently, I'm trying to migrating my application from CakePHP to Grails. So far it's been a smooth sailing, everything I can do with CakePHP, I can do it with much less code in Grails. However, I have one question :

In CakePHP, there's an URL Prefix feature that enables you to give prefix to a certain action url, for example, if I have these actions in my controller :

PostController
admin_add
admin_edit
admin_delete

I can simply access it from the URL :

mysite/admin/post/add
mysite/admin/post/edit/1
mysite/admin/post/delete/2

instead of:

mysite/post/admin_add
mysite/post/admin_edit/1
mysite/post/admin_delete/2

Is there anyway to do this in Grails, or at least alternative of doing this?

A: 

I didn't test it, but try this:

"mysite/$prefix/$controller/$method/$id?"{
    action = "${prefix}_${method}"
}

It constructs the action name from the prefix and the method.

Daniel Engmann
I've tried this, but the problem is, I need to repeat this for all actions...
Furuno
+1  A: 

Just take a look on grails URL Mappings documentation part

amra