-
-
Save tlberglund/5f8ea69ebff26ef8a4ea to your computer and use it in GitHub Desktop.
A hint for the book creation code in the Ratpack workshop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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