- create-app blog
- create-domain-class post
- Edit Post.groovy:
- package blog
class Post {
String title
String content
Date date
static constraints = { }
} - generate-all blog.Post
- create-domain-class comment
- Add comments to Post.groovy:
- class Post {
String subject
String content
Date date
static hasMany = [comments: Comment]
static constraints = {
// Ordering constraint
subject()
content()
date()
comments() }
} - generate-all *
- add to views/post/show.gsp
- <g:link class="comment" action="comment" id="${postInstance?.id}"><g:message code="default.button.comment.label" default="Comment" /></g:link>
Snippets and thoughts from a passionate software developer interested in all things DevOps, Continuous Delivery, Functional Programming, Distributed Systems. Also on Twitter as @mcallana.