1
votes

Having some mega frustration set in.Maybe Im trying grails too much like rails and active record.

I have 2 domains.The parent is called 'report' and the child 'category'.

The user creates a new report and if they like they can add a category. The report can only have one category. However I would like to allow reports to be sorted by category or listed by category or even counted by category. Yes this column could go into the reports domain but I would like separation for future cases. so below I have my domains;

Domain 1 = Report

class Report

string reportname
string reportype

Domain 2 = category

class Category

Report report

string categoryname

I have 2 controllers, 1 for report 1 for category both with crud methods and no scaffold.

How do I set the view to create/edit/update the category domain while in the report _form? I have read through the gorm docs, grails docs, others but still am stumbling on this.

Do I need to edit my report controller to handle the category domain? i.e import category and supply category def with each method for /edit/update/create.

Do I need to edit the report form to get the report params and pass this into a hidden field for the category name field so that when a save action is called the category domain commits the cat name and reportId.

Is my model all wrong? I have tried hasone, hasmany belongsto however I need to keep the category separate from the reports because I want to be able to show a page of reports separated by categories and allow only unique category names for a bunch of reports to reduce spelling mistakes in category names. i.e. I want to set a category name and associate it to a report.

New to grails so forgive me. Maybe I need to sit and have a beer and read more. cheers

1

1 Answers

0
votes

There are many ways to handle your scenario. One way to do this is to use redirect in your ReportController and pass in the params to CategoryController.