Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails form submit causes 404

Tags:

grails

I have created a very simple form for signing up a user

<g:form name="signupForm" url="[controller:'users', action:'signup']">
  <g:textField name="username" placeholder="Username" />
  <g:passwordField name="password" placeholder="Password" />
  <g:textField name="email" placeholder="Email" />
  <g:actionSubmit class="right" value="Signup" action="update" />
</g:form>

When I click the submit button I get a 404 error The requested resource is not available. However, if I navigate to the exact same URL manually (or even just select the address bar on the 404 error page and press enter) then it works!

My controller looks like this, it's very simple.

class UsersController {
    def signup() {
        render "Hello World"
    }
}

Sorry if this is a noob question, but I've looked all over the Grails docs and can't figure out why this is happening. Any help much appreciated. Thanks.

like image 823
The Sockmonster Avatar asked Nov 11 '12 12:11

The Sockmonster


1 Answers

The g:actionSubmit has the parameter action="update" which will push it to the UsersController def update which isn't there so it will throw a 404.

You can remove the action="update" or add that action to the controller.

http://grails.org/doc/latest/ref/Tags/actionSubmit.html

There is also a g:submitButton you can use instead.

http://grails.org/doc/latest/ref/Tags/submitButton.html

like image 99
Jeff Beck Avatar answered Oct 23 '22 08:10

Jeff Beck