Skip to content

Commit

Permalink
Docs updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvaro Sanchez-Mariscal committed Apr 30, 2012
1 parent 972362b commit a459c3b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -21,12 +21,12 @@ class Book {
String title
String sanitizedTitle
def beforeInsert() {
sanitizedTitle = title.asFriendlyUrl()
def beforeValidate() {
if (!sanitizedTitle) sanitizedTitle = title?.asFriendlyUrl()
}
static constraints = {
sanitizedTitle unique:true //As an alternative, you may decide to make sanitizedTitle replace default id.
sanitizedTitle unique:true //As an alternative, you may decide to make sanitizedTitle replace the default id.
}
}
```
Expand All @@ -36,7 +36,7 @@ And given the following URL mapping:
class UrlMappings {
static mappings = {
"/book/$title"(controller:'book', action:'show')
"/book/$sanitizedTitle"(controller:'book', action:'show')
"/$controller/$action?/$id?"{
constraints {
Expand All @@ -54,7 +54,7 @@ You can do the following in your controller:
class BookController {
def show() {
[book: Book.findBySanitizedTitle(params.title)]
[book: Book.findBySanitizedTitle(params.sanitizedTitle)]
}
}
Expand Down

0 comments on commit a459c3b

Please sign in to comment.