krasinski
krasinski

Reputation: 69

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

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?

Upvotes: 1

Views: 53

Answers (1)

Dónal
Dónal

Reputation: 187499

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.

Upvotes: 1

Related Questions