我正在使用rails 3.2,我必须设置一个页面的背景,我已经尝试了许多方法,没有什么是正确的,所以寻找一些很好的帮助。我努力了
background: url(<%= asset_path 'background.jpg' %>) background: url("public/background.jpg"); background-image:url('/assets/images/background.jpg')
没有任何工作。请帮帮我。
解决方法
在你的CSS:
background-image: url(background.jpg);
要么
background-image: url(/assets/background.jpg);
在environments / production.rb中:
# Disable Rails's static asset server (Apache or Nginx will already do this) config.serve_static_assets = false # Compress JavaScripts and CSS config.assets.compress = true # Don't fallback to assets pipeline if a precompiled asset is missed config.assets.compile = false # Generate digests for assets URLs config.assets.digest = true