A model (see: Model-View-Controller pattern) in Grails is represented by a so-called Domain Class. Domain classes can define both the persistence and presentation of information in grails. Domain classes can also contain validations.
To manage a fleet of cars in your Grails application you could define a domain class to describe, store and represent various cars in your fleet.
To create a stub for a domain class execute the following command inside your application folder:
grails create-domain-class org.fleetmanager.Car
Next, open the generated car.groovy file and edit your domain class as follows:
package org.fleetmanager
class Car {
String manufacturer
String model
String color
Integer year
Date acquisitionDate
Boolean isElectric
}
Finally, generate a controller for your car domain and a view using the following Grails command:
grails generate-all org.fleetmanager.Car
Now, you can run your applications, select the car controller and manage your fleet.