Last Updated: February 25, 2016
·
1.092K
· nosolopau

Using multiple layouts with Rails assets pipeline

If we want to use the stylesheet widget.css from a specific layout (not the layouts/application.html.erb one) we can include it using in our layout (layouts/widget.html.erb in my example):

<%= stylesheet_link_tag "widget", media: "all", "data-turbolinks-track" => true %>

The, we need to include this line in the application.rb file to add the asset to the pipeline:

config.assets.precompile += %w(widget.css)