tags:

views:

379

answers:

1

I'm working through the "Grails in Action" book, and I'm stuck at that part that introduces the grails console. From my project directory, I typed "grails console" to open a console window, and the console even output information indicating it was compiling classes, but when I type this into the console:

new Quote(author:'Larry Wall',content:'There is more than one method to our madness.').save()

I get this error:

unable to resolve class Quote 
 at line: 1, column: 1

The Quote class exists in Quote.groovy in grails-app/domain/qotd/Quote.groovy, and I'm not able to run the above command.

What's going wrong here?

+2  A: 

Did you try importing the package that contains your domain class before trying to instantiate it?

import qotd.Quote
new Quote(author:'Larry Wall',content:'There is more than one method to our madness.').save()

to be sure you can also try specifying the full qualified name:

new qotd.Quote(author:'Larry Wall',content:'There is more than one method to our madness.').save()
Jack
Odd. Since the book didn't mention it, I assumed I was getting auto-import magic, or something.
Stefan Kendall
import qotd doesn't work, either. Only the fully qualified name seems to work :/
Stefan Kendall
That should either be "import qotd.Quote" or "import qotd.*" just like in Java
Burt Beckwith
Oh, righto. Ack.
Stefan Kendall
Yep, typo sorry.. I was thinking too groovish
Jack