Вопрос

I've successfully extended some SASS functions with Ruby code (http://sass-lang.com/docs/yardoc/Sass/Script/Functions.html#adding_custom_functions), and my extensions are loading correctly in development, but when I precompile my assets, the extensions are not loaded. The code lives in /app/models, but this is probably not the best place for it.

I've tried explicitly requiring the file in a few different config files, but it continues to fail to load during precompile. This also seems like a poor approach.

I know that the code is failing to load because the precompiled CSS leaves the function names in the CSS in plaintext. No errors are thrown.

So: Where's the best place for a file like this to live, and how do I get SASS to load the file during precompile?

Это было полезно?

Решение

The problem ended up being that I was requiring the file incorrectly, was using the config root rather than the app root. Assumed an error would be thrown when trying to include a nonexistent file, but evidently not. Once, I required the file correctly in config/application.rb, the precompile was able to access my SASS extensions

require "#{Rails.root}/lib/assets/colorable.rb"
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top