Skip to content

Instantly share code, notes, and snippets.

@tlberglund
Created December 5, 2013 13:45
Show Gist options
  • Select an option

  • Save tlberglund/5f8ea69ebff26ef8a4ea to your computer and use it in GitHub Desktop.

Select an option

Save tlberglund/5f8ea69ebff26ef8a4ea to your computer and use it in GitHub Desktop.
A hint for the book creation code in the Ratpack workshop.
handler("create") {
byMethod {
get {
render groovyTemplate("create.html", title: "Create Book")
}
post {
def form = parse form()
def ids = sql.executeInsert("insert into books (title, content) values ($form.title, $form.content)")
def id = ids[0][0]
redirect "/?msg=Book+$id+created"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment