method
stylesheet_link_tag
stylesheet_link_tag(*sources)
public
Returns a stylesheet link tag for the sources specified as arguments. If you don’t specify an extension, .css will be appended automatically. You can modify the link attributes by passing a hash as the last argument. For historical reasons, the ‘media’ attribute will always be present and defaults to “screen”, so you must explicitly set it to “all” for the stylesheet(s) to apply to all media types.
If the server supports Early Hints header links for these assets will be automatically pushed.
stylesheet_link_tag "style" # => <link href="/assets/style.css" media="screen" rel="stylesheet" /> stylesheet_link_tag "style.css" # => <link href="/assets/style.css" media="screen" rel="stylesheet" /> stylesheet_link_tag "http://www.example.com/style.css" # => <link href="http://www.example.com/style.css" media="screen" rel="stylesheet" /> stylesheet_link_tag "style", media: "all" # => <link href="/assets/style.css" media="all" rel="stylesheet" /> stylesheet_link_tag "style", media: "print" # => <link href="/assets/style.css" media="print" rel="stylesheet" /> stylesheet_link_tag "random.styles", "/css/stylish" # => <link href="/assets/random.styles" media="screen" rel="stylesheet" /> # <link href="/css/stylish.css" media="screen" rel="stylesheet" />
Register or
log in
to add new notes.
slawosz -
April 6, 2009
3 thanks
Assets hosts
You can also setup assets hosts in enviroments:
config.action_controller.asset_host = "http://your-assets-server.com"