acts-as-mobile

Adds mobile-specific methods to ActionController and ActionView.

iPhone requests should reroute to format :mobile. iPad requests will remain :html, but can be tested for using the ipad? helper method

Usage

Gemfile

gem 'acts-as-mobile', :require => 'acts_as_mobile'

Controller

class MyController < ActionController::Base
  acts_as_mobile

  def index
    puts "rendering mobile" if mobile?
    puts "rendering ipad" if ipad?

    respond_to do |format|
      format.html
      format.mobile
    end
  end
end

View

<html>
<body>
  <div><%= "Rendered from iPad" if ipad? %></div>
</body>
</html>

Copyright © 2010 Eric Saxby. See LICENSE for details.