A simple way to build iPhone specific interface with Rails
- class ApplicationController < ActionController::Base
- exempt_from_layout('iphone_html.erb')
- before_filter :check_iphone
- protected
- def iphone?
- request.user_agent.include?('iPhone')
- end
- def check_iphone
- if iphone?
- request.parameters[:format] = 'iphone_html'
- end
- end
- end
- class DashboardController < ApplicationController
- def index
- @top_movies = Movie.top_movies
- @movie = @top_movies.first
- respond_to do |format|
- format.html # index.html.erb
- format.iphone_html #index.iphone_html.erb
- end
- end
- end
