Sprockets require file from parent directory
-
29-10-2019 - |
Question
I am trying to use the rails 3.1 asset pipeline to include a javascript file from the manifest file's parent directory
app/assets/javascripts/folder/index.js
//=require ../file
yields: couldn't find file 'file'
How do I require a file from the parent directory?
Solution
Assets in Sprockets are always referenced by their logical path.
So you just have to use //=require file
if your file is in /app/assets/javascripts
.
If your file was /lib/assets/javascripts/models/lala.js
for instance, you would require it with //=require models/lala
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow