Class Mime::Type
In: lib/action_dispatch/http/mime_type.rb
Parent: Object

Encapsulates the notion of a mime type. Can be used at render time, for example, with:

  class PostsController < ActionController::Base
    def show
      @post = Post.find(params[:id])

      respond_to do |format|
        format.html
        format.ics { render :text => post.to_ics, :mime_type => Mime::Type["text/calendar"]  }
        format.xml { render :xml => @people.to_xml }
      end
    end
  end

Methods

Constants

TRAILING_STAR_REGEXP = /(text|application)\/\*/
Q_SEPARATOR_REGEXP = /;\s*q=/

Attributes

symbol  [R] 

Public Class methods

input: ‘text’ returned value: [Mime::JSON, Mime::XML, Mime::ICS, Mime::HTML, Mime::CSS, Mime::CSV, Mime::JS, Mime::YAML, Mime::TEXT]

input: ‘application’ returned value: [Mime::HTML, Mime::JS, Mime::XML, Mime::YAML, Mime::ATOM, Mime::JSON, Mime::RSS, Mime::URL_ENCODED_FORM]

Registers an alias that‘s not used on mime type lookup, but can be referenced directly. Especially useful for rendering different HTML versions depending on the user agent, like an iPhone.

This method is opposite of register method.

Usage:

Mime::Type.unregister(:mobile)

Public Instance methods

Returns true if Action Pack should check requests using this Mime Type for possible request forgery. See ActionController::RequestForgeryProtection.

[Validate]