开发中的ERB未处理Rails Asset Path中的CSS [英] CSS in Rails Asset Path not processed by ERB in development

查看:87
本文介绍了开发中的ERB未处理Rails Asset Path中的CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在/app/assets/stylesheets/styles.css.erb中有一个具有以下内容的Rails应用程序:

I have a Rails app with the following in /app/assets/stylesheets/styles.css.erb:

...
#nestedbg {
    background-position: left top;
    background-image: url(<%= asset_path 'siteheader2.png' %>);
    background-repeat: repeat-x;
    background-attachment: fixed;
}
...

当我运行rake assets:precompile然后运行rails s -e production时,一切都会按预期进行.但是,当我删除预编译的资产并在开发中运行rails s时,CSS文件就会如上图所示出现,而不是被正确替换了.

When I run rake assets:precompile and then run rails s -e production, everything works as expected. However, when I remove the precompiled assets and run rails s in development, the CSS file comes up as shown above instead of being properly substituted.

我尝试将config.assets.compile = true放入/config/environments/development.rb,但这没有帮助.

I tried putting config.assets.compile = true in /config/environments/development.rb and that did not help.

有什么想法吗? 谢谢.

Any ideas? Thanks.

推荐答案

我正在使用Rails 3.1.1,当我将应用程序切换为使用Rails 3.1.3时,问题就消失了.我切换回3.1.1,以查看问题是否再次出现.

I was using Rails 3.1.1 and when I switched the app to use Rails 3.1.3, the problem went away. I switched back to 3.1.1 to see if the issue came back and it did not.

我猜这是其中一个gem的问题,对3.1.3的更新带来了其他gem更新.

I'm guessing that it was a problem with one of the gems and the update to 3.1.3 brought other gem updates with it.

这篇关于开发中的ERB未处理Rails Asset Path中的CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆