Proper way of creating object using a form in its parents view?

64 views Asked by At

Let's say I have two classes: News (hasMany Comment) Comment (belongsTo News)

In single news object view (news/show.gsp) I'm listing comments belonging to it after it's content. Then I want to have a form which will allow some user (but security isn't a case here) to add new comment, and then show the same (news) view again.

Seems easy, but I couldn't find the anwser: What is the proper way of doing it in Grails?

1

There are 1 answers

0
Dónal On

If you run grails generate-all News and grails generate-all Comment on the command-line, Grails will generate views and controller actions that allow you to CRUD each entity. If you read the generated code for the create and save actions and views of CommentController, that should set you straight.