I have a custom theme for my rails app. This theme consists of 8 folder with complex structure (subfolders, lots of files). One of these folders is bootstrap which consist of css, js and img subfolder. Some other folders and subfolder also contain css, js and imgages.
How can I use assets pipeline to precompile these files and how to access them from code?
I recently purchased a large HTML5 theme and performed the work to get it into my rails project and using the asset pipeline. There was some bulk find/replace I had to do to get it happy with image URLs. Here is the overall approach I used:
/vendor/assets/images.
/vendor/assets/stylesheets
/vendor/assets/javascripts
With the above approach, all relative paths should be maintained as the theme vendor wanted them. For instance, my theme vendor had all images under an ‘img’ directory, so I simply copied that directory so it was /vendor/assets/images/img/…
Now, we need to get our application.css and application.js files to properly pull in the files it needs:
Now the tricky part depends on whether or not your javascripts and stylesheets included other items. For any files that did, I recommend you rename them to .erb (add a .erb to the filename) which allows you to use the rails helpers such as asset_path and image_path:
Or, in your javascript:
Once you’ve fixed any image paths you should be ready to go with the new theme, and it will work with the Asset pipeline!
Warning: I spent hours debugging an asset compilation problem with a theme and it turned out it was because one of the images had a parenthesis in the filename and the sass compiler was gagging on that!