Skip to content

Instantly share code, notes, and snippets.

@joeRinehart
Created October 18, 2012 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joeRinehart/3911330 to your computer and use it in GitHub Desktop.
Save joeRinehart/3911330 to your computer and use it in GitHub Desktop.
Grails for the Wicked Smaht 2
def ajaxShow() {
render Person.get( params.personId ) as JSON
}
def company = new Company( "Acme" )
def person = new Person( firstname : "Bob", lastname : "Bobbyson", age : 80 )
company.addToPeople( person )
company.save()
person.findByFirstName( "Bob" ) // finds all "Bob"s
person.findAll( "from Person where Company = :company", [ company: company ] )
company.delete()
class PersonController {
def show() {
def person = Person.get( params.personId )
return [ person: person ]
}
}
class Person {
String firstname
String lastname
Integer age
void setFirstname( String firstname ) {
println "Setting firstname to ${firstname}"
this.firstname = firstname
}
}
class Person {
String firstname
String lastname
Integer age
static constraints = [
name size: 1...50
age nullable: true
]
}
You just loaded ${person.firstname} ${person.lastname}.
def literal = 'John'
def gString = "The name is ${literal}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment