1. intro
  2. features
  3. setup guide
  4. source
Rails-portlet – JSR286 webapp portlet

Setup for running Rails in Liferay portlets

So far, the minimum setup and versions known to work:

If you want a quickstart and run an example application (Rails 2.3.8), configured to comply given Liferay (5.2.3) Tomcat bundle, you need to touch less configuration files. For preparing your own application, see the Caterpillar README.

gem install caterpillar
git clone git://github.com/lamikae/rails-portlet.git
cd rails-portlet/
git submodule init
git submodule update

Further commands and filenames refer to the rails-portlet directory.

If you do want to use a (PostgreSQL) database connection, edit the configuration file example/config/environment.rb. ActiveRecord is disabled by default.
Also set up the database connection; file example/config/database.yml. You may check the examples in that directory.

# enable ActiveRecord
- config.frameworks -= [:active_record, :active_resource, :action_mailer ]
+ #config.frameworks -= [:active_record, :active_resource, :action_mailer ]

Start the example application server at example.

cd example
./script/server
. . and navigate to http://localhost:3000/doc/defaultsetup.html, where you should find this document.

Rails is now running. Now, the Liferay setup:

Download the Liferay 5.2.3 Tomcat 6 bundle from liferay.com.

cd /usr/local
unzip liferay-portal-tomcat-6.0-5.2.3.zip
sudo chown -R `whoami` liferay-portal-5.2.3 # give yourself proper privileges

If you chose another installation directory, check the configuration file example/config/portlets.rb with your settings.
Install the required JAR (recommended with each Caterpillar update) by returning to the example Rails directory:

cd example
caterpillar jar:install

The example application hosts the portlet test bench. Install the XML for this portlet:

caterpillar deploy:xml

Then you're ready to boot up Liferay.

cd /usr/local/liferay-portal-5.2.3/tomcat-6.0.18
bin/startup.sh && sleep 4 && tail -f logs/catalina.out

You should see lines like this in the output:

Starting Liferay Portal Standard Edition 5.2.3 (Augustine / Build 5203 / May 20, 2009)
...
19:19:36,655 INFO [Rails286Portlet:?] Initializing Rails-portlet portlet_test_bench (version 0.10.0)
...
INFO: Server startup in 46419 ms

Finally, restart the example application server in production mode..

cd example
RAILS_ENV=production ./script/server
Then you're ready to browse to http://localhost:8080/. Login (click on "login as Bruno"), then add a new page and open it. On an empty page click on 'add application' on the JavaScript menu on the upper right corner. You should see the 'Caterpillar' category. Open it and add the test bench.

Railstestbench