module ActionView::Helpers::AssetTagHelper::StylesheetTagHelpers
def stylesheet_link_tag(*sources)
stylesheet_link_tag :all, :concat => true
you have too many stylesheets for IE to load.
To force concatenation (even in development mode) set :concat to true. This is useful if
stylesheet_link_tag :all, :cache => true, :recursive => true
The :recursive option is also available for caching:
stylesheet_link_tag "shop", "cart", "checkout", :cache => "payment" # when config.perform_caching is true =>
stylesheet_link_tag "shop", "cart", "checkout", :cache => "payment" # when config.perform_caching is false =>
stylesheet_link_tag :all, :cache => true # when config.perform_caching is true =>
stylesheet_link_tag :all, :cache => true # when config.perform_caching is false =>
==== Examples
environment). Examples:
is set to true (which is the case by default for the Rails production environment, but not for the development
compressed by gzip (leading to faster transfers). Caching will only happen if config.perform_caching
You can also cache multiple stylesheets into one file, which requires less HTTP connections and can better be
== Caching multiple stylesheets into one
stylesheet_link_tag :all, :recursive => true
If you want Rails to search in all the subdirectories under stylesheets, you should explicitly set :recursive:
stylesheet_link_tag :all # =>
You can also include all styles in the stylesheets directory using :all as the source:
stylesheet_link_tag "random.styles", "/css/stylish" # =>
stylesheet_link_tag "style", :media => "print" # =>
stylesheet_link_tag "style", :media => "all" # =>
stylesheet_link_tag "http://www.example.com/style.css" # =>
stylesheet_link_tag "style.css" # =>
stylesheet_link_tag "style" # =>
==== Examples
apply to all media types.
to "screen", so you must explicitely set it to "all" for the stylesheet(s) to
For historical reasons, the 'media' attribute will always be present and defaults
You can modify the link attributes by passing a hash as the last argument.
you don't specify an extension, .css will be appended automatically.
Returns a stylesheet link tag for the sources specified as arguments. If
def stylesheet_link_tag(*sources) @stylesheet_include ||= StylesheetIncludeTag.new(config, asset_paths) @stylesheet_include.include_tag(*sources) end
def stylesheet_path(source)
stylesheet_path "http://www.example.com/css/style" # => http://www.example.com/css/style
stylesheet_path "/dir/style.css" # => /dir/style.css
stylesheet_path "dir/style.css" # => /stylesheets/dir/style.css
stylesheet_path "style" # => /stylesheets/style.css
==== Examples
Used internally by +stylesheet_link_tag+ to build the stylesheet path.
Full paths from the document root will be passed through.
If the +source+ filename has no extension, .css will be appended (except for explicit URIs).
Computes the path to a stylesheet asset in the public stylesheets directory.
def stylesheet_path(source) asset_paths.compute_public_path(source, 'stylesheets', :ext => 'css', :protocol => :request) end