include_tags with the asset pipeline

Posted . Visible to the public.

You can include files from app/assets or from the public folder with javascript_include_tag. The subtle difference that tells rails how to build the path correctly is a single slash at the beginning of the path:

<%= javascript_include_tag('ckeditor/config') %> # for assets/ckeditor/config.js
<%= javascript_include_tag('/ckeditor/ckeditor') %> # for public/ckeditor/ckeditor.js

This also applies to stylesheet_link_tag.

Note that when you refer to a Javascript or stylesheet in /assets you need to add it to the list of assets that Rails will precompile.

Judith Roth
Last edit
Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Judith Roth to makandra dev (2015-08-20 12:19)