Letting the user know when you are talking back Lightweight Development, NOT, Lightweight Container
Jul 04

Grails: Groovy on Rails

Groovy, Tech Add comments

It was bound to happen. The Groovy folk have seen the boon from Ruby on Rails, and want to get in on some of that action :)

A discussion of Grails (Groovy on Rails) sparked up on the mailing list, and miracles happen… code has come out of it.

Steven Devijver put together the first 0.0001 release of this code:

A first version of Grails is available in CVS. It’s located under groovy/modules/grails. Currently simple controllers are implemented together with JSP support. The MVC part is based on Spring MVC.

Build the project via “ant jar”

To start your own project with Grails set the GRAILS_HOME environment variable. Next create a directory for your project and from within this directory run this command:

ant -f ${GRAILS_HOME}/src/grails/build.xml -Dbasedir=`pwd` init

to initialize the project directory structure.

Place your controllers under the grails-app directory and your JSP’s under the jsp directory. A simple controller in Grails looks like
this:

class NamesController {
@Property String namesView = “names”
@Property Closure names = {
request, response ->

return [ "names" : [ "John", "Jill", "Jack", "Jaqueline" ] ]
}
}

Then make sure to create a view.

To create a WAR for deployment run this command:

ant -f ${GRAILS_HOME}/src/grails/build.xml -Dbasedir=`pwd` war

This will create a war names grails-app.war.

When the WAR is deployed access it through this URI:

/grails-app/app/names

Obviously, this is insanely early days. It is so interesting to see how people are revisiting their way of dealing with web applications after Rails.

One Response to “Grails: Groovy on Rails”

  1. Calvin Xiu Says:

    It looks more like “groovy on Spring”, than “groovy on rails”:(
    It did’t get the essential of rails.

Leave a Reply

Spam is a pain, I am sorry to have to do this to you, but can you answer the question below?

Q: Type in the word 'cricket'