Ruby on Rails 2.0: Leopard and iPhone

By lbois

Ruby on Rails 2.0 has been released on 6th of December.

If you already use Ruby on Rails, please update by typing the following command in a Terminal Window on Leopard:

gem update rails

This new release includes new features, loads of fixes, and an incredible amount of polish.

Improvements in ActionPack Multiview  : after the already existing respond_to, improvements have been done to separate the format for the template from the rendering engine. And Mime::IPHONE is supported with facilities.

example:

 # should go in config/initializers/mime_types.rb
  Mime.register_alias "text/html", :iphone

  class ApplicationController < ActionController::Base
    before_filter :adjust_format_for_iphone

    private
      def adjust_format_for_iphone
        if request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(iPhone|iPod)/]
          request.format = :iphone
        end
      end
  end

  class PostsController < ApplicationController
    def index
      respond_to do |format|
        format.html   # renders index.html.erb
        format.iphone # renders index.iphone.erb
      end
    end 
  end

All the improvements on the Ruby on Rails Weblog

Tags: , , ,

Leave a Reply