instance method
format
Ruby on Rails 2.3.18
Since v2.3.18 Last seen in v2.3.18Signature
format()
Returns the Mime type for the \format used in the request.
GET /posts/5.xml | request.format => Mime::XML GET /posts/5.xhtml | request.format => Mime::HTML GET /posts/5 | request.format => Mime::HTML or MIME::JS, or request.accepts.first depending on the value of <tt>ActionController::Base.use_accept_header</tt>
Source
# File actionpack/lib/action_controller/request.rb, line 154
def format
@format ||=
if parameters[:format]
Mime::Type.lookup_by_extension(parameters[:format])
elsif ActionController::Base.use_accept_header
accepts.first
elsif xhr?
Mime::Type.lookup_by_extension("js")
else
Mime::Type.lookup_by_extension("html")
end
end
Defined in actionpack/lib/action_controller/request.rb line 154
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionController::Request