grails / grails-guides

Repository for Guides to using Grails
Apache License 2.0
12 stars 25 forks source link

Missing code line in "Creating your first Grails Application" guide #11

Closed Frankst2 closed 5 years ago

Frankst2 commented 7 years ago

I've noticed that in section "7 Services" in the "Creating your first Grails Application" guide some line of code seems to be missing:

Now, let’s use our new service.

Edit grails-app/controllers/org/grails/guides/VehicleController.groovy (the scaffolded controller we generated earlier), and add the property shown below: grails-app/controllers/org/grails/guides/VehicleController.groovy

import static org.springframework.http.HttpStatus.CREATED import org.grails.guides.Vehicle import grails.transaction.Transactional

@SuppressWarnings(['LineLength']) @Transactional(readOnly = true) [1]

[1] By simply defining a property in our controller with the same name as our service class, Grails will inject a reference to the service for us.

[1] points to the Transactional line, I guess it should say something with "def ..." here.

Also something else seems to be wrong here:

Now (still editing VehicleController.groovy), modify the show action as seen below: grails-app/controllers/org/grails/guides/VehicleController.groovy

params.max = Math.min(max ?: 10, 100)
respond Vehicle.list(params), model:[vehicleCount: Vehicle.count()]

}

I guess the code signature of the show method is missing here? As the max property does not exist by default for the show action (only does for the index action).

niravassar commented 5 years ago

yes thank you. I fixed these. It will be done in the new grails 4.0 version of this guide