Search code examples
grailsgsp

g:link ignoring named mapping


I have the following named UrlMapping

name 'admin_user' :"/admin/user/$action?/$id?"(controller:'userAdmin')

On a different page site/edit.gsp (/admin/site/edit) I am calling:

<g:link  mapping="admin_user" action='create' class="create" >New User</g:link>

But its generating

/admin/site/create

basically ignoring my mapping parameter. Any help on what I a doing wrong?


Solution

  • So I finally got down to the bottom of this it was an issue with two url mappings that conflicted.

    name 'admin_user' :"/admin/user/$action?/$id?"(controller:'userAdmin')
    "/$controller/$action?/$id?"()
    

    It was ignoring the first and always using the second. I eventually had to just abandon using the admin prefix and actually go with /admin/userAdmin/ I defined

    "/admin/$controller/$action?/$id?"()
    

    And then used createLink with controller='userAdmin'.

    Whenever I needed a link to /user/xxx I explicitly defined it.

    Big pain in the arse....