Question

I have 3 domain classes: Article, User & Language. Every article is written by a user in a specified language. So the relation are (Article - Language : many - 1), (User - Article : 1 - many)

I try:

class Product {

  static belongsTo = [user:User]
  static belongsTo = [language:Language]

  ...
}

class User {

  static hasMany = [products:Product]

   ...
}

class Language {

  static hasMany = [products:Product]

  ...
}

Here's the problem: grails generate-all can create all the controllers & views for all 3 domain class, but with no properties input in any view. No text input, no combo box, no error message,... only the id field for Product, Language, and Article.

I'm pretty sure the error is about how I use relationship, because when I drop "belongsTo" & "hasMany", grails create all the view without any trouble.

Did I do anything wrong?

Was it helpful?

Solution

You can explicitly add a property user (camel-case) to Article, and scaffolding will generate for it. Or you can tweak scaffolding template (after grails [install-templates][1]) to use not only explicitly declared properties.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top