Hello, I'm new here and just starting to get acqua...
# questions
p
Hello, I'm new here and just starting to get acquainted with grails. Going through the documentation I tried the cli command "grails generate-controller Book" to create CRUD controllers with scaffolding, but I get the following message back: "Unmatched arguments from index 0: 'generate-controller', 'Book' Did you mean: grails create-controller or grails create-interceptor or grails create-service?" I'm using Grails Version: 6.2.0 JVM Version: 17.0.12 I would appreciate if someone could point out what I'm doing wrong or whether there is some problem with grails 6.2.0.
j
generate-controller comes from the Grails Scaffolding Plugin. In Grails 6.2.0, the CLI is Grails Forge, which will not execute plugin commands, in favor of executing them from Gradle. So you have a few options:
grails create-controller Book
that will generate a controller, although not as complete as generate-controller Execute generate-controller through gradle - https://docs.grails.org/6.2.0/ref/Command%20Line/generate-controller.html
p
Thanks James, I will try this out. When starting it's always nice to have some canvas generated for you. In the meantime I also found this in a "Grail 6 anouncement" "The Grails Scaffolding Plugin The Grails Scaffolding plugin, which defines commands such as generate-all and generate-controller, will not work because it uses the command scripts. In Grails 3, we introduced the concept of an ApplicationCommand which has similar abilities as scripts in regards to retrieving arguments, template generation, file access, and model building. For more information, please read the Grails documentation for (creating custom commands)[https://docs.grails.org/latest/guide/commandLine.html#creatingCustomCommands]" It would be nice if the Grails 6.2.0 documentation would be clear/correct about how you have to implement static scaffolding from the CLI. Is there a channel to suggest updates to the documentation?
With gradlew the "generate-all" nicely creates the BookController, but when clicking the "New Book" menu option that has been created in my menu, I get the following error: "*URI* /myapp/book/create Class org.grails.taglib.GrailsTagException Message Request processing failed; nested exception is org.grails.gsp.GroovyPagesException: Error processing GroovyPageView: [Byte array resource [view , ,bookcreate]:40] [Byte array resource [view , ,bookcreate]:35] Tag [all] currently only supports domain types Caused by [Byte array resource [view , ,bookcreate]:40] [Byte array resource [view , ,bookcreate]:35] Tag [all] currently only supports domain types" I don't quite understand all this, but it looks like relying on the scaffolding to create CRUD operations will not be working.
j
For any documentation that is outdated you can create an issue on https://github.com/grails/grails-core/issues or if you can, create a pull request with the specific changes against that repository. in views/book/create.gsp, the form should look like the following. The error in on
<f:all bean="book"/>
Copy code
<g:form resource="${this.book}" method="POST">
    <fieldset class="form">
        <f:all bean="book"/>
    </fieldset>
    <fieldset class="buttons">
        <g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" />
    </fieldset>
</g:form>
p
Thanks once more, for your kind guidance. No view has been created by the generate-all command, in the "views" directory of the application. Which I already found strange.
j
Here is a good sample Grails 6.2.0 project, not mine, that you can clone and kick the tires on. It was created about the same way you are attempting. following the documentation. https://github.com/codeconsole/website
p
Thanks a lot James. I will give it some rest for now and pick up my exploration tomorrow with this sample. It's a pity that the documentation of this platform is rather poor towards beginners, because it looks like offering a lot of powerful tools.