Grails connect database fields
<p>I'm trying to learn Grails but am still pretty much on beginner level.
I made a tiny application, where you can basically add events, and people can write reviews about them and rate them. 
So I have an eventController and reviewController. The rating is just an Integer in a review. But now I want to show an overall rating for an event. So the events rating should be the average value of the corresponding ratings value.</p>

<p>This is my event domain code where the rating is initially set, I left out the constraints and toString:</p>

<pre><code>class Event {
Double dRating = 2

static hasMany = [ratings:Rating]

}
</code></pre>

<p>The controller is simply:</p>

<pre><code>class EventController {

def scaffold = Event
}
</code></pre>

<p>The rating domain file:</p>

<pre><code>class Rating {
   String comment
   java.util.Date date = new java.util.Date()
   Integer rating
   Event event
}
</code></pre>

<p>and the Rating Controller is:</p>

<pre><code>class RatingController {
    def scaffold = Rating
}
</code></pre>

<p>Hope I didn't make mistakes, I had to translate variable names so they're understandable.</p>

<p>I'm guessing that where dRating is set, I could somehow add some calculation, but I don't even know how to access the values of the rating, and everything I try ends in lots of errors and having to restart the app again and again. I tried adding calculations in the controller, but there I don't know how to get the value into the database. So where do I actually put the logic, and how do I access the values?</p>

<p>If any other file is important, please tell me.</p>

<p>Hoping to get some hints on how to start doing this, I didn't think it would be this hard.</p>