instance method
format=
Ruby on Rails 8.1.2
Since v3.0.20Signature
format=(extension)
Sets the format by string extension, which can be used to force custom formats that are not controlled by the extension.
class ApplicationController < ActionController::Base before_action :adjust_format_for_iphone private def adjust_format_for_iphone request.format = :iphone if request.env["HTTP_USER_AGENT"][/iPhone/] end end
Parameters
-
extensionreq
Source
# File actionpack/lib/action_dispatch/http/mime_negotiation.rb, line 174
def format=(extension)
parameters[:format] = extension.to_s
set_header "action_dispatch.request.formats", [Mime::Type.lookup_by_extension(parameters[:format])]
end
Defined in actionpack/lib/action_dispatch/http/mime_negotiation.rb line 174
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionDispatch::Http::MimeNegotiation