The Artima Developer Community
Sponsored Link

Ruby Community News Forum
Ruby on Rails 1.2 Released

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Bill Venners

Posts: 2251
Nickname: bv
Registered: Jan, 2002

Ruby on Rails 1.2 Released Posted: Jan 19, 2007 3:54 PM
Reply to this message Reply
Summary
After a long period of development, the latest update to the Ruby on Rails framework was released. Rails 1.2 introduces several hundred new features, the most significant ones focusing on RESTful services and better utilization of the HTTP protocol.
Advertisement

The Ruby on Rails project released its latest Web development framework, Rails 1.2. The minor version update notwithstanding, Rails 1.2 introduces several hundred new features to the popular Ruby-based Web application toolkit.

The most significant changes relate to APIs that help implement RESTful Web services. REST support infuses every tier of Rails 1.2. In keeping with Rails' tradition of providing code generation scripts for common tasks, a single command, generate scaffold_resource foo creates RESTful model, controller, and view elements for an entity foo.

In announcing the Rails 1.2 release, Rails creator David Heinemeier-Hansson encouraged developers to rethink their controller designs around RESTful principles:

Start thinking about how your application could become more RESTful. How you too can transform that 15-action controller into 2-3 new controllers each embracing a single resource with CRUDing love. This is where the biggest benefit is hidden: A clear approach to controller-design that’ll reduce complexity for the implementer and result in an application that behaves as a much better citizen on the general web.

In tandem with the ability to generate RESTful controllers, Rails 1.2 controllers can also serve up responses based on the type of content a client prefers. For instance, Web service clients preferring XML can be served an XML response, and clients preferring HTML will be provided with an HTML output from the same controller method. Again, Heinemeier-Hansson provides more details about this in his blog:

We’ve added a small tweak in 1.2 that ends up making a big difference for immediate usefulness of the feature. That is the magic of :format. All new applications will have one additional default route: map.connect ':controller/:action/:id.:format'. With this route installed, imagine the following example:

class WeblogController < ActionController::Base
  def index
    @posts = Post.find :all
    respond_to do |format|
      format.html
      format.xml { render :xml => @posts.to_xml }
      format.rss { render :action => "feed.rxml" }
    end
  end
end

GET /weblog     # returns HTML from browser Accept header
GET /weblog.xml # returns the XML
GET /weblog.rss # returns the RSS

Using the Accept header to accomplish this is no longer necessary. That makes everything a lot easier. You can explore your API in the browser just by adding .xml to an URL. You don’t need a before_filter to look for clues of a newsreader, just use .rss. And all of them automatically works with page and action caching.

Additional Rails 1.2 features include better support for multi-byte character sets, new ActiveRecord [Rails' object-relational mapping] features, and several features that provide better Ajax integration.

What do you think of Rails 1.2's REST support?

Topic: Antonio Cangiano Benchmarks Seven Ruby Implementations Previous Topic   Next Topic Topic: Charles Nutter on Why JRuby Needed a New Interpreter


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us