pieterk
pieterk

Reputation: 295

Has URL Mappings changed in Grails 1.3.7?

The situation:

Say I have an example controller called AccountController with some actions of show, edit and update.

In the Grails URL Mappings I am trying to map by method type e.g. GET POST etc etc

Then I have a link that points to the controllers corresponding action like so:

<g:link controller="account" action="edit">Edit my account link</g:link>

with the mappings of:

"/profile"      (controller: "account", action: "show")
"/profile/edit" (controller: "account", action: [GET: "edit", POST: "update"])

the problem here is the link that is generated should be using the mappings for lookups and making it look like so "/profile/edit" in the generated html page but instead the page has "/account/edit" which according to the mappings don't exist so just causes an error when clicked.

I have even tried the alternative syntax of:

"/profile/edit" (controller: "account") { action = [GET: "edit", POST: "update"] }

but it still points to a url mapping that does not exist.

Is this a bug or just me having a bad day?

Upvotes: 1

Views: 761

Answers (1)

deluan
deluan

Reputation: 1865

I don't know if this (reverse URL mappings with HTTP methods) was working in previous versions of Grails, but I have reproduced your problem here in 1.3.7 and the only solution I came up with was to use named URL mappings. Using it, your tag would be:

<g:link controller="account" action="edit" mapping="profileEditing">
    Edit my account link
</g:link>

and the edit mapping would be:

name profileEditing: "/profile/edit" (controller: "account") {
    action = [GET: "edit", POST: "update"]
}

Regards.

Upvotes: 2

Related Questions