Created
January 10, 2012 12:49
-
-
Save donnior/1588907 to your computer and use it in GitHub Desktop.
Revisions
-
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ #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