Rails erb preprocessing not happening in development mode

こ雲淡風輕ζ 提交于 2019-12-25 07:38:10

问题


For whatever reason, this first attempt at dynamic styling gets me a Sass::SyntaxError on the line below. It looks like the erb is not being pre-processed.

/* app/assets/stylesheets/variables.css.scss.erb */

$headerHeight: <%= '15px' %>;

It's in development mode. Any idea what could cause this?

Here are my configuration options relating to assets in case that helps:

# Application
config.assets.enabled = true
config.assets.initialize_on_precompile = true
config.assets.version = '1.1'

# Development
config.assets.compress = false
config.assets.debug = false

回答1:


The scss needs quotes around the 15px part. So you will need to make it:

$headerHeight: "<%= '15px' %>";



回答2:


This is a sass-rails error, as discussed here.

I had the same question and found out that the solution is by installing sass-rais-path.

This gets Rails to work SASS + ERB as expected. No need to use quotes.



来源:https://stackoverflow.com/questions/13376733/rails-erb-preprocessing-not-happening-in-development-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!