formats=(extensions)
Instance Public methods
Sets the formats by string extensions. This differs from format= by allowing you to set multiple, ordered formats, which is useful when you want to have a fallback.
In this example, the :iphone format will be used if it's available, otherwise it'll fallback to the :html format.
class ApplicationController < ActionController::Base before_action :adjust_format_for_iphone_with_html_fallback private def adjust_format_for_iphone_with_html_fallback request.formats = [ :iphone, :html ] if request.env["HTTP_USER_AGENT"][/iPhone/] end end
Please login to continue.