1
votes

In grails I am trying to get every instance of a domain called Child to be printed out for that authorized user.

I am using the following:

 <g:each var="child" in="${Child}">
    <p>Name: ${child.firstname}</p>
    <p>Surname: ${child.lastname}</p>
 </g:each>

Each user can have several children (Child) and I want it to list the children for the currently logged in user. I am using spring source security core plugin for my login etc.

This is my exception:

Class : groovy.lang.MissingPropertyException Message : No such property: firstname for class: com.fyp.timeline.Child Possible solutions: firstname, lastname

Any ideas?

1

1 Answers

5
votes
<g:each var="child" in="${user.children}">
   <p>Name: ${child.firstname}</p>
   <p>Surname: ${child.lastname}</p>
</g:each>

user is an instance of logged in user where

User{
    static hasMany=[children:Child]
}