#config/initializers/mime_types.rb Mime::Type.register_alias "text/html", :iphone #Make a copy of app/views/layouts/application.html.erb calling it application.iphone.erb #Make copies of the necessary view files in your controllers, calling them things like index.iphone.erb #in Controller respond_to :html, :iphone #in ApplicationController def self.responder MobileResponder end class MobileResponder < ActionController::Responder def to_format super rescue ActionView::MissingTemplate => e if request.format == "iphone" navigation_behavior(e) else raise unless resourceful? api_behavior(e) end end end #in ApplicationController, set iphone format in before_filter。。。!!Maybe not need? before_filter :check_format def check_format if request.env["HTTP_USER_AGENT"].downcase.match(/iphone/) request.format = "iphone" end end