module ActionDispatch::Http::MimeNegotiation

def formats=(extensions)

end
end
request.formats = [ :iphone, :html ] if request.env["HTTP_USER_AGENT"][/iPhone/]
def adjust_format_for_iphone_with_html_fallback
private

before_action :adjust_format_for_iphone_with_html_fallback
class ApplicationController < ActionController::Base

to the :html format.
In this example, the :iphone format will be used if it's available, otherwise it'll fallback

to set multiple, ordered formats, which is useful when you want to have a fallback.
Sets the \formats by string extensions. This differs from #format= by allowing you
def formats=(extensions)
  parameters[:format] = extensions.first.to_s
  @env["action_dispatch.request.formats"] = extensions.collect do |extension|
    Mime::Type.lookup_by_extension(extension)
  end
end