Martin
Martin

Reputation: 1458

Learning Grails, Definitive guide to Grails, 2nd ed. Stuck on Urlmapping in chapter 4

I'm learning Grails from the Definitive Guide (2nd ed), and get stuck on the Urlmapping used.
I'm buidling the gTunes store, as many before me must have done.

The book makes me change the default mapping in:

  class UrlMappings {
      static mappings = {
         "/"(controller:"store")
     }
   }

On the form rendered by the "store"'s default action, there is this code:

<div id="registerPane">
        Need an account? 
        <g:link controller="user" action="register">Signup now</g:link> 
        to start your own personal Music collection!
</div>

clicking, the server returns the message "The requested resource (/gTunes/user/register) is not available."

I have a register.gsp in NetBeansProjects\gTunes\grails-app\views\user

If I change the UrlMappings to it's original, click on StoreController in the original Homepage, and then click SignUp it works. So the problem lies in the mapping used as specified in the book. I found the ERRATA for the first but not for the second edition.

Upvotes: 0

Views: 333

Answers (3)

Chris Mitchell
Chris Mitchell

Reputation: 904

This is not in the book, but the solution here fixes the problem. The book apparently uses 1.1 version of grails.

Upvotes: 0

Roberto Guerra
Roberto Guerra

Reputation: 360

Sorry, missed a ? after action:

    class UrlMappings {
      static mappings = {

         "/"(controller:"store")
         "/$controller/$action?/$id?"{
            constraints{
            }
       }
     }
   }

Upvotes: 1

Roberto Guerra
Roberto Guerra

Reputation: 360

Your URLMappings seems incomplete. it should be:

class UrlMappings {
      static mappings = {

         "/"(controller:"store")
         "/$controller/$action/$id?{
            constraints{
            }
       }
     }
   }

Upvotes: 0

Related Questions