add_flash_types

add_flash_types(*types) Instance Public methods Creates new flash types. You can pass as many types as you want to create flash types other than the default alert and notice in your controllers and views. For instance: # in application_controller.rb class ApplicationController < ActionController::Base add_flash_types :warning end # in your controller redirect_to user_path(@user), warning: "Incomplete profile" # in your view <%= warning %> This method will automatically

send_file

send_file(path, options = {}) Instance Protected methods Sends the file. This uses a server-appropriate method (such as X-Sendfile) via the Rack::Sendfile middleware. The header to use is set via config.action_dispatch.x_sendfile_header. Your server can also configure this for you by setting the X-Sendfile-Type header. Be careful to sanitize the path parameter if it is coming from a web page. send_file(params[:path]) allows a malicious user to download any file on your server. Opti

send_data

send_data(data, options = {}) Instance Protected methods Sends the given binary data to the browser. This method is similar to render plain: data, but also allows you to specify whether the browser should display the response as a file attachment (i.e. in a download dialog) or as inline data. You may also set the content type, the apparent file name, and other things. Options: :filename - suggests a filename for the browser to use. :type - specifies an HTTP content type. Default

stale?

stale?(record_or_options, additional_options = {}) Instance Public methods Sets the etag and/or last_modified on the response and checks it against the client request. If the request doesn't match the options provided, the request is considered stale and should be generated from scratch. Otherwise, it's fresh and we don't need to generate anything and a reply of 304 Not Modified is sent. Parameters: :etag. :last_modified. :public By default the Cache-Control header is private,

fresh_when

fresh_when(record_or_options, additional_options = {}) Instance Public methods Sets the etag, last_modified, or both on the response and renders a 304 Not Modified response if the request is already fresh. Parameters: :etag. :last_modified. :public By default the Cache-Control header is private, set this to true if you want your application to be cachable by other devices (proxy caches). Example: def show @article = Article.find(params[:id]) fresh_when(etag: @article, l

expires_now

expires_now() Instance Public methods Sets a HTTP 1.1 Cache-Control header of no-cache so no caching should occur by the browser or intermediate caches (like caching proxy servers).

expires_in

expires_in(seconds, options = {}) Instance Public methods Sets a HTTP 1.1 Cache-Control header. Defaults to issuing a private instruction, so that intermediate caches must not cache the response. expires_in 20.minutes expires_in 3.hours, public: true expires_in 3.hours, public: true, must_revalidate: true This method will overwrite an existing Cache-Control header. See www.w3.org/Protocols/rfc2616/rfc2616-sec14.html for more possibilities. The method will also ensure a HTTP Date h

etag

etag(&etagger) Instance Public methods Allows you to consider additional controller-wide information when generating an etag. For example, if you serve pages tailored depending on who's logged in at the moment, you may want to add the current user id to be part of the etag to prevent authorized displaying of cached pages. class InvoicesController < ApplicationController etag { current_user.try :id } def show # Etag will differ even for the same invoice when it's vie

cache

cache(key, options = {}, &block) Instance Protected methods Convenience accessor.

view_cache_dependencies

view_cache_dependencies() Instance Public methods