Plugins You can find out about all the publicly available Grails plugins.


  • Tags: /
  • Latest: 1.0.M3
  • Last Updated: 25 October 2011
  • Grails version: 1.2 > *
  • Authors: Bobby Warner
0 vote
compile "org.grails.plugins:ruby:1.0.M3"

 Documentation  Source  Issues


Plugin for using Ruby code in Grails via JRuby.


grails install-plugin ruby


Ruby Plugin

The Ruby plugin provides easy access to execute Ruby code from any Grails artifact (controllers, taglibs, services etc...)


To install the Ruby plug-in just run the following command from within an existing Grails project:

grails install-plugin ruby


The plugin expects to find Ruby source files under the src/ruby/ directory. The directory is created for you when the plugin is installed. Ruby source files in a Grails project should have the .rb extension.

For example, src/ruby/hello_world.rb might look like this:

class RubyHelloWorld
    def create_greeting(name, greeting)
        time =
        day = time.strftime("%A")
        "#{greeting} #{name}! Today is #{day}."

def greet(name, greeting) hello_world = hello_world.create_greeting(name, greeting) end

With that code in place, the greet function may be executed by using the dynamic property named ruby from any Grails artifact. See below:

class HomeController {
    def hi() {
        ruby.put('name', 'Bobby')
        ruby.put('greeting', 'Hi')
        render ruby.eval('greet($name, $greeting)')

def bye() { ruby.put('name', 'Bobby') ruby.put('greeting', 'Bye') render ruby.eval('greet($name, $greeting)') } }

The Dynamic Property

The dynamic property will be named ruby by default. In a future version of the plugin, this property name will be configurable.


Ruby Plugin on GitHub


Your feedback is welcome via GitHub. Please share what you would like to see provided by the plugin or fork it and send a pull request!


Release Notes

Version 1.0.M3

  • JRuby upgraded to 1.6.5
  • Grails upgraded to 2.0.0.RC1

Version 1.0.M2

  • Plugin was cleaned up from initial release

Version 1.0.M1

  • JRuby 1.6.4
  • Require Grails 1.2 or later (tested on 1.2.5, 1.3.7 and 2.0.0.M2)