Skip to Main Content
JRuby Cookbook
book

JRuby Cookbook

by Justin Edelson, Henry Liu
November 2008
Intermediate to advanced content levelIntermediate to advanced
224 pages
5h 2m
English
O'Reilly Media, Inc.
Content preview from JRuby Cookbook

Chapter 2. JRuby on Rails

Introduction

Since its introduction in mid-2004, the Ruby on Rails web framework has rapidly gained a significant following within the web development community. It is the single largest factor in the overall increase in interest in the Ruby programming language. Likewise, JRuby’s ability to run Rails applications inside a Java Virtual Machine has been a driver for interest in JRuby. This chapter explores some techniques for running Rails applications in a Java environment.

Ruby on Rails is a framework for developing web applications that follows the model-view-controller (MVC) architecture. The notion of Convention over Configuration is stressed throughout the framework, most prevalently within ActiveRecord, the object-relational-mapping (ORM) subsystem. ActiveRecord uses database metadata (table and column names) to dynamically define domain classes. Using ActiveRecord, simply adding a new column to a database table automatically adds a corresponding field to the related domain class.

Running Rails applications on JRuby provides several advantages:

  • Rails applications can be deployed into existing Java EE containers such as Tomcat, JBoss, and GlassFish.

  • Through Java Database Connectivity (JDBC), Rails applications can be connected to virtually any database for which a JDBC driver exists.

  • Rails applications can access container-managed database connection pools through Java Naming and Directory Interface (JNDI).

In short, the combination of JRuby and Rails produces ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ruby Cookbook, 2nd Edition

Ruby Cookbook, 2nd Edition

Lucas Carlson, Leonard Richardson
Groovy 2 Cookbook

Groovy 2 Cookbook

Andrey Adamovich, Luciano Fiandesio
Mastering Ruby Closures

Mastering Ruby Closures

Benjamin Tan Wei Hao
Ruby Phrasebook

Ruby Phrasebook

Jason Clinton

Publisher Resources

ISBN: 9780596155063Errata Page