InfoQ

News

Ruby on Rails 1.2 deepens support to REST and Unicode

Posted by Luciano Ramalho on Jan 21, 2007 03:33 PM

Community
Ruby
Topics
Ruby on Rails
Tags
Unicode,
REST,
Announcements,
Releases

Ruby on Rails 1.2 is finally out, as a release numbered 1.2.1 that updates many key components of the framework. 'Mature' is perhaps the best adjective to describe the latest version. The most important change is arguably "REST, and general HTTP appreciation", to quote the official announcement. In other words, the framework now leverages more advanced features of HTTP. For instance, CRUD operations can now be directly mapped to the native HTTP verbs POST, GET, PUT and DELETE. REST-style mapping simplifies URLs by reducing the need for naming actions in the path, and paves the way to refactoring bloated controllers into simpler, more focused ones. Another major enhancement is better support for UTF-8 encoded strings.

David Heinemeier Hansson appears to have pored over Roy Fielding's PhD dissertation, which defines the acronym REST (Representational State Transfer) as the architectural style of the Web. Fielding is one of the founders of the Apache project, the lead author of the HTTP/1.1 standard, and his work put HTTP and the whole WWW on solid theoretical grounds.

Besides using additional HTTP verbs, Rails controllers can now render multiple formats from the same base URL invoked with different file extensions (i.e. /blog and /blog.rss both invoke the /blog controller, but one renders HTML and the other RSS). David's keynote at the 2006 RailsConf (video, slides) previews these changes, and shows how they support his opinionated (and agile) approach to SOAs without the baggage of SOAP. By digging into HTTP, the Rails team once again shows an easy to follow path towards building web apps the right way.

Ruby is set to finally support Unicode by the end of 2007. Meanwhile, the Rails team has created a Chars class to proxy the native String class and provide encoding-safe operations, such as a slice method that does not mangle multibyte characters. ActiveSupport::Multibyte adds a String::char accessor which returns a Char instance representing the String, so if you do title.chars[0,7] you get a Char instance containing the first seven Unicode characters of the title string (and not the first seven bytes).

It's reassuring the see the Rails team committed not to bells and whistles, but to perfecting the architecture and the infrastructure of the framework. Another sign of maturity: 57 distinct developers sign the changelog for 1.2, more than twice the number in the previous minor releases (27 in 1.1, 18 in 1.0). There are 108 items in the 1.2 changelog, versus 62 in 1.1, which was released in March, 2006. Ruby on Rails definitely seems poised for another year of explosive growth.

5 comments

Reply

action in the url? by Dan Diephouse Posted Jan 22, 2007 6:59 AM
Re: action in the url? by Obie Fernandez Posted Jan 22, 2007 7:37 AM
Re: action in the url? by James Strachan Posted Jan 22, 2007 9:51 AM
Re: action in the url? by David Easley Posted Jan 24, 2007 7:03 AM
Re: action in the url? by Stefan Tilkov Posted Jan 25, 2007 8:29 AM
  1. Back to top

    action in the url?

    Jan 22, 2007 6:59 AM by Dan Diephouse

    Anyone else notice how they are sometimes putting ";edit" in the URL to map it to the edit action? I'm not a Rails expert, but that seems a bit non-RESTful to me. Anyone want to comment what the difference between the edit and the update actions are for a non Rails guy? Dan Diephouse, Envoi Solutions

  2. Back to top

    Re: action in the url?

    Jan 22, 2007 7:37 AM by Obie Fernandez

    Adding ;edit to an individual resource URL tells Rails that you want the edit form in order to do an update (via a PUT)

  3. Back to top

    Re: action in the url?

    Jan 22, 2007 9:51 AM by James Strachan

    Dan, the ";edit" on the URL is purely as a work around for browsers and firewalls which don't support PUT/DELETE - so its a way of differentiating operations when only GET and POST are supported. i.e. its a way to support loREST as well as hiREST. Basically you can use Rails in a perfectly RESTful way - the REST support in Rails is awesome (as is the rest of it :). James LogicBlaze

  4. Back to top

    Re: action in the url?

    Jan 24, 2007 7:03 AM by David Easley

    > the ";edit" on the URL is purely as a work around for > browsers and firewalls which don't support PUT/DELETE Wrong. There's a separate hidden field in the POSTed form for that. ";edit" is essentially a hint used with a GET URL. It says to the server "Give me the specified resource in an appropriate format for editing". So "GET /users/1" might return the user details formatted as a report while "GET /users/1;edit" returns the user details in a form. If and when the form is the browser sends the form params to "PUT /users/1". Except, because of the problem Dan mentioned, PUT can't be relied to work, so instead POST is used and a hidden form field is used to signal to the webapp framework that it should treat it as a PUT. David

  5. Back to top

    Re: action in the url?

    Jan 25, 2007 8:29 AM by Stefan Tilkov

    There's nothing unRESTful about that ;edit URI. Doing a GET on it is "safe", the only difference is the one pointed out by David. I asked the combined REST commuity about the Rails REST concepts in the Yahoo! mailing list; IIRC, there was no significant criticism. The only exception is the hidden form field workaround, which is used not only by Rails, but also by Google's GData (for example) -- some consider this wrong and believe applications should not try to work around the PUT/DELETE limitations in many firewalls. The reasoning is that firewall admins a) need to learn the errors of their ways b) have good reasons for blocking PUT and DELETE. I don't subscribe to this point of view.

Exclusive Content

Rationalizing the Presentation Tier

Thin client paradigm characterized by web applications is a kludge that needs to be repudiated. Old compromises are no longer needed and it's time to move the presentation tier to where it belongs.

Agile Project Management: Lessons Learned at Google

In this presentation filmed during QCon 2007, Jeff Sutherland, the creator of Scrum, talks about his visit at Google to do an analysis of Google's first implementation of Scrum.

AtomServer – The Power of Publishing for Data Distribution

In this article, Bryon Jacob and Chris Berry introduce AtomServer, their implementation of a full-fledged Atom Store based on Apache Abdera, which is now available as open source.

An Introduction to Virtualization

It is easy to think that virtualization applies only to servers. In reality the recent resurgence of the concept is also being applied to networking, storage, and application infrastructure.

REST Anti-Patterns

In this article, Stefan Tilkov explains some of the most common anti-patterns found in applications that claim to follow a "RESTful" design and suggests ways to avoid them.

Choosing between Routing and Orchestration in an ESB

In this article, Adrien Louis and Marc Dutoo discuss the differences and relative merits of using orchestration vs. routing in a typical ESB setup, and discuss various implementation options.

Enterprise Batch Processing with Spring

Wayne Lund discusses batch processing, Spring Batch objectives and features, scenarios for usage, Spring Batch architecture, scaling, example code, failures and retrying, and the future roadmap.

User Story Estimation Techniques

Developer Jay Fields draws on his experiences as a ThoughtWorks consultant to describe effective user story estimation techniques.