Grails3.0.1框架视图不显示域关系
我遵循《Grails快速入门指南》一书中的示例,使用Grails 3.0.1和以下域Grails3.0.1框架视图不显示域关系,grails,scaffolding,Grails,Scaffolding,我遵循《Grails快速入门指南》一书中的示例,使用Grails 3.0.1和以下域 package com.tekdays class TekEvent { static constraints = { name() city() description maxSize:5000 organizer() venue() startDate() endDate()
package com.tekdays
class TekEvent {
static constraints = {
name()
city()
description maxSize:5000
organizer()
venue()
startDate()
endDate()
}
String city
String name
TekUser organizer
String venue
Date startDate
Date endDate
String description
static hasMany = [volunteers: TekUser, respondents: String]
String toString(){
"$name, $city, $organizer"
}
}
及
之后我用
grails generate-all "*"
然后是init/BootStrap.groovy
class BootStrap {
def init = { servletContext ->
def user1 = new TekUser(fullName: 'John Doe',
userName: 'jdoe',
password: 't0ps3cr3t',
email: 'jdoe@johnsgroovyshop.com',
website: 'blog.johnsgroovyshop.com',
bio: '''John has been programming for over 40 years. He has
worked with every programming language known to man
and has settled on Groovy. In his spare time, John
dabbles in astro physics and plays
shuffleboard.''').save(flush: true, failOnError: true)
def event1 = new TekEvent(name: 'Gateway Code Camp',
city: 'Saint Louis, MO',
organizer: TekUser.findByFullName('John Doe'),
venue: 'TBD',
startDate: new Date('11/21/2013'),
endDate: new Date('11/21/2013'),
description: '''This conference will bring coders from
across platforms, languages, and industries
together for an exciting day of tips, tricks,
and tech! Stay sharp! Stay at the top of your
game! But, don't stay home! Come an join us
this fall for the first annual Gateway Code
Camp.''')
println "before event1.save"
if(!event1.save()){
event1.errors.allErrors.each{error ->
println "An error occured with event1: ${error}"
}
}
}//init
def destroy = {
}
}
当我访问时,它会显示除屏幕截图中显示的TekUser
属性之外的所有属性
!![1] :您看到的是此问题,解决后将解决此问题
class BootStrap {
def init = { servletContext ->
def user1 = new TekUser(fullName: 'John Doe',
userName: 'jdoe',
password: 't0ps3cr3t',
email: 'jdoe@johnsgroovyshop.com',
website: 'blog.johnsgroovyshop.com',
bio: '''John has been programming for over 40 years. He has
worked with every programming language known to man
and has settled on Groovy. In his spare time, John
dabbles in astro physics and plays
shuffleboard.''').save(flush: true, failOnError: true)
def event1 = new TekEvent(name: 'Gateway Code Camp',
city: 'Saint Louis, MO',
organizer: TekUser.findByFullName('John Doe'),
venue: 'TBD',
startDate: new Date('11/21/2013'),
endDate: new Date('11/21/2013'),
description: '''This conference will bring coders from
across platforms, languages, and industries
together for an exciting day of tips, tricks,
and tech! Stay sharp! Stay at the top of your
game! But, don't stay home! Come an join us
this fall for the first annual Gateway Code
Camp.''')
println "before event1.save"
if(!event1.save()){
event1.errors.allErrors.each{error ->
println "An error occured with event1: ${error}"
}
}
}//init
def destroy = {
}
}