Skip to content
Robert Oschwald edited this page Sep 18, 2015 · 4 revisions

Adding Dynamic Finder to Query given object's history

  1. Add "import org.codehaus.groovy.grails.plugins.orm.auditable.AuditLogEvent" to the domain class.
  2. Add the following code to the domain class to specify the getChanges method:
List getChanges() { 
  AuditLogEvent.findAllByClassNameAndPersistedObjectId(
                    this.getClass().getName(), this.id) 
}
  1. Add to your Controller:
def show = { 
  def domainInst = YourDomain.get(params.id) 
  def domainChanges = domainInst.getChanges() 
  return [domainInst: domainInst, domainChanges:domainChanges] 
}
  1. Add apropriate views for the new Controller class to query the audit log for the changes and to list them.
Clone this wiki locally