Skip to content

Instantly share code, notes, and snippets.

@olivermt
Created May 22, 2014 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olivermt/383665ed62c7d00afe4a to your computer and use it in GitHub Desktop.
Save olivermt/383665ed62c7d00afe4a to your computer and use it in GitHub Desktop.
def save() {
def item = new Page(params)
if(item.validate()) {
item.save(flush:true)
respond item
}
else {
render(status: 422, item.errors as JSON)
}
}
| Error 2014-05-22 15:12:03,762 [http-bio-8080-exec-1] ERROR errors.GrailsExceptionResolver - PSQLException occurred when processing request: [POST] /api/page - parameters:
content: asjdajhdlaslkjdha
title: foo
pageName: tech
secured: 1
ERROR: duplicate key value violates unique constraint "page_page_name_key"
Detail: Key (page_name)=(tech) already exists.. Stacktrace follows:
Message: ERROR: duplicate key value violates unique constraint "page_page_name_key"
Detail: Key (page_name)=(tech) already exists.
package no.cipr.safari.auxiliary
class Page {
String pageName, title, content
Boolean secured
static constraints = {
pageName(unique: true, blank: false)
title(blank: false)
content(blank: false)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment