Home > SOA Tips > The Web Services Advisor > Web services with Ruby on Rails
SOA Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

THE WEB SERVICES ADVISOR

Web services with Ruby on Rails


William Brogden
11.27.2007
Rating: -2.86- (out of 5)


Enterprise IT tips and expert advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


Ruby was a rather obscure object-oriented dynamically typed "scripting language" until it suddenly got a lot of notice due to the appearance of the Rails Web application framework. The combination quickly became known as Ruby on Rails, I suppose because that creates a better image than Rails on Ruby - in any case, we can use the "RoR" acronym.

As an interpreted language, Ruby performance is not particularly spectacular, but due to the popularity of RoR, serious effort is being applied to change this. The original interpreter was written in C, but there are now versions in Java ( JRuby), .NET ( IronRuby) and probably other languages. The current stable version of Ruby is 1.8.6, released in March of this year. A significant update to version 1.9 and a major upheaval update to version 2.0 are anticipated.

What is Rails?

The Rails Web application framework does not attempt to become all things to all developers. It concentrates on applications using relational databases and the Model-View-Controller design pattern. Ruby on Rails was initially created by David Hansson while working at the Web design company 37signals on a project management tool. The first open source version was released in 2004. Web developers discovered that RoR made creating database-oriented Web applications extremely easy and industry "buzz" was quickly generated.

Developers found that the many built in assumptions and naming conventions in RoR greatly reduce the lines of code needed to get a basic web application going. Naming conventions replace the complex XML configuration files typical of other Web application frameworks. RoR fans express this with the mantra "Convention over configuration."

RoR version 1.2 was released i...


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
The Web Services Advisor
What to expect with the new JavaScript standardization (ECMAScript 5)
Restlet framework wrestles RESTful Web applications
3 tips for choosing whether to use EGL
Use SoaML to facilitate Model Driven Architecture
Enterprise mashup patterns act as API enablers
XQuery learns to write using XUF
Descriptive Languages for RESTful Services
Notable Python language update on view
Try XML-based Extensible Business Reporting Language (XBRL) for accounting reports
Whatever happened to ''X''?

Ruby on Rails
Ruby on Rails Tutorial
Sun previews GlassFish V3 ahead of Java EE6 release
Learn about Ruby on Rails programming
SOA ends era of big apps, opens door for Ruby on Rails
Where Ruby on Rails fits into SOA
How Ruby on Rails and REST go together
Is Ruby on Rails ready for enterprise SOA?
Investors on Rails
WSO2 releases Ruby framework
MyEclipse supports Cold Fusion

Representational State Transfer (REST)
Restlet framework wrestles RESTful Web applications
Mulesoft architect talks REST, ESBs
How do I balance throughput requirements and interoperability?
IBM Sabbah's say on REST for collaborative ALM
Report on REST- REpresentational State Transfer
Are tools available to work with OSGi today?
Expert Query: What is the difference between RESTful transactions and Web Services transactions?
Progress/Actional SOA diagnostic tool builds on Mindreef purchase
SOA goes beyond 'rip, replace, repeat'
Inside the SOA big tent; Azure at PDC; more

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
Project Metro  (SearchSOA.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


n October 2007 and incorporates many improvements including REST style request support. Rails 2.0, currently at the "release candidate 1" stage, promises even more REST support. SOAP support is available, but Rails developers are encouraging the REST approach.

MVC and Web applications

The Model-View-Controller design pattern first found expression in Smalltalk, the pioneering object-oriented language developed at Xerox. Many developers have found that thinking in MVC terms helps to clarify the architecture of complex applications.

Model

By placing all aspects of data storage and retrieval in a "Model" component, a developer can isolate details behind a well defined interface. You might start a project using a model that contains fake data, move to one with the same interface backed by an in-memory database and finally graduate to a large scale commercial database with no change to other parts of the project.

In Rails applications, a model class builds on base classes, which provide all basic functionality. One custom model class is created for each database table, drawing the names from the table to create the access methods. The RoR tools provide Ruby scripts which can generate source code skeletons for model classes automatically.

View

A "View" is responsible for rendering data in a particular style. These days a Web application might need to support a number of different views. Although RoR was originally intended for HTML pages, the newer editions can also support formats used in Web services. Views are typically generated from a template file which contains elements that always appear, such as HTML markup tags, plus tags which are evaluated dynamically with data from one or more models.

RoR provides base classes supporting view generation in HTML, XML and JavaScript styles. The following table suggests some corresponding clients. JSON stands for JavaScript Object Notation, a format that can convey complex data just like XML, but with savings in speed and bulk.

FormatClientsExample
HTMLTypical browserA HTML page filled in with user specific information
XMLBrowser using JavaScriptAJAX style dynamic page
JSONBrowser using JavaScriptDynamic page using JSON instead of XML
JSON Web Service ClientPython and a variety of other languages support JSON parsing

XML templates could be used to create simple SOAP messages, but it appears that most attempts to create SOAP or XML-RPC Web services with RoR have put a lot of output generation into the controller component, thus straying from a strict MVC pattern. The SOAP service examples I could find do not implement the more advanced WS-* features found in other frameworks. RoR developers appear to be putting much more emphasis on REST style Web services for future development.

Controller

A "Controller" typically interprets inputs from a user or server request to decide which model objects will be used for data, the actions to be taken and which view will generate the response. Controller classes can take advantage of a large library of helper classes for dealing with HTML elements. Recent versions of RoR have increase support for REST style requests by creating controller base classes, which can interpret request URLs in REST terms.

Legal status of Ruby and Rails

The Ruby language is copyrighted free software with its own license conditions. The Rails framework is released under the extremely open conditions of the MIT License. David Hansson has filed for trademark protection on the use of "RUBY ON RAILS", "RAILS" and the official Rails logo. The initial attempt to create a parallel development based on the Java-based scripting language Groovy, known as Groovy on Rails, met with an objection from Hansson so the project is now known as Grails and appears to be doing its own thing.

Platforms for RoR

The Rails open source developers are generally using Apple Mac OS X, and the recently released OS X version 10.5, called Leopard, includes RoR. Windows and Linux based developers should have no problem installing Ruby and once you have the Ruby language installed, the "RubyGems" package manager can take care of installing the latest Rails distribution. You will also need a relational database, but RoR can work with most of the popular open source and commercial systems. MySQL, SQLite and PostgreSQL are popular choices. There are also various bundle packages that include a web server and database for even simpler installation.

The popular IDEs (Integrated Development Environments) Netbeans and Eclipse have added modules which support Ruby coding. There are also several projects to create IDEs specifically to support RoR. Most of these appear to be based on Eclipse.

Conclusions

RoR has mainly been used to create browser-based Web applications. Due to the flexibility of the Model-View-Controller design pattern, such applications can be extended to cover a variety of clients without changing the data model components. Developers who feel that the SOAP approach to Web services has just gotten too complex will be attracted to RoR for the REST support.

References

Ruby on Rails API introduction

Ruby as a Web service client language

This Wikipedia survey article cites many commercial projects using RoR


Rate this Tip
To rate tips, you must be a member of SearchSOA.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



SOA Trends and Strategy - SOA Education, SOA Development, SOA Implementations
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2001 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts